<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><div id="myscoll"></div><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>Js对象 | 晚夜微雨问海棠のBlog</title><meta name="keywords" content="Js,对象"><meta name="author" content="晚夜微雨问海棠"><meta name="copyright" content="晚夜微雨问海棠"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="这是小生对 Js对象 的一些拙见,有不对之处还望评论区留言,以便及时更正  函数编程和面向对象的实例对比 函数编程形式：  1234567891011&#x2F;&#x2F;  函数编程形式    let name &#x3D; &amp;#x27;浩果锅&amp;#x27;    let grade &#x3D; [      &amp;#123; name: &amp;#x27;js&amp;#x27;, score: 99 &amp;#125;,      &amp;#123; nam">
<meta property="og:type" content="article">
<meta property="og:title" content="Js对象">
<meta property="og:url" content="http://example.com/posts/2f85c503.html">
<meta property="og:site_name" content="晚夜微雨问海棠のBlog">
<meta property="og:description" content="这是小生对 Js对象 的一些拙见,有不对之处还望评论区留言,以便及时更正  函数编程和面向对象的实例对比 函数编程形式：  1234567891011&#x2F;&#x2F;  函数编程形式    let name &#x3D; &amp;#x27;浩果锅&amp;#x27;    let grade &#x3D; [      &amp;#123; name: &amp;#x27;js&amp;#x27;, score: 99 &amp;#125;,      &amp;#123; nam">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic1.zhimg.com%2Fv2-bde07fdceb700b45ea02f16e3bb099e7_1440w.jpg%3Fsource%3D172ae18b&refer=http%3A%2F%2Fpic1.zhimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1664442254&t=5014ff2160d57c4fbfe0a74d94815bf2">
<meta property="article:published_time" content="2022-11-12T03:28:51.681Z">
<meta property="article:modified_time" content="2022-09-25T12:41:59.997Z">
<meta property="article:author" content="晚夜微雨问海棠">
<meta property="article:tag" content="JS">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic1.zhimg.com%2Fv2-bde07fdceb700b45ea02f16e3bb099e7_1440w.jpg%3Fsource%3D172ae18b&refer=http%3A%2F%2Fpic1.zhimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1664442254&t=5014ff2160d57c4fbfe0a74d94815bf2"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="http://example.com/posts/2f85c503"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//fonts.googleapis.com" crossorigin=""/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="manifest" href="/manifest.json"/><meta name="msapplication-TileColor" content="#49b1f5"/><link rel="apple-touch-icon" sizes="180x180" href="/img/siteicon/128.png"/><link rel="icon" type="image/png" sizes="32x32" href="/img/siteicon/32.png"/><link rel="icon" type="image/png" sizes="16x16" href="/img/siteicon/16.png"/><link rel="mask-icon" href="/img/siteicon/128.png" color="#5bbad5"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Titillium+Web&amp;display=swap" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":false,"languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"简"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":150},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: true,
    post: true
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: {"limitCount":650,"languages":{"author":"作者: 晚夜微雨问海棠","link":"链接: ","source":"来源: 晚夜微雨问海棠のBlog","info":"著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。"}},
  lightbox: 'fancybox',
  Snackbar: {"chs_to_cht":"你已切换为繁体","cht_to_chs":"你已切换为简体","day_to_night":"你已切换为深色模式","night_to_day":"你已切换为浅色模式","bgLight":"#49b1f5","bgDark":"#1f1f1f","position":"top-right"},
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: true,
  isAnchor: true
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'Js对象',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2022-09-25 20:41:59'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="/css/custom.css" media="defer" onload="this.media='all'"> <link rel="stylesheet" href="/swiper/swiper.min.css"> <link rel="stylesheet" href="/swiper/swiperstyle.css"> <link rel="stylesheet" href="/css/rightMenu.css"> <link rel="stylesheet" href="/css/constrain.css"><!-- hexo injector head_end start --><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper/swiper-bundle.min.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Zfour/Butterfly-card-history/baiduhistory/css/main.css"><link rel="stylesheet" href="https://npm.elemecdn.com/hexo-butterfly-categories-card@1.0.0/lib/categorybar.css"><link rel="stylesheet" href="https://cdn.cbd.int/hexo-butterfly-clock-anzhiyu/lib/clock.min.css" /><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Zfour/Butterfly-double-row-display@1.00/cardlistpost.min.css"/>
<style>#recent-posts > .recent-post-item >.recent-post-info > .article-meta-wrap > .tags:before {content:"\A";
  white-space: pre;}#recent-posts > .recent-post-item >.recent-post-info > .article-meta-wrap > .tags > .article-meta__separator{display:none}</style>
<link rel="stylesheet" href="https://cdn.cbd.int/anzhiyu-blog@2.0.3/css/runtime/runtime.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.cbd.int/hexo-butterfly-swiper-anzhiyu@1.0.4/lib/swiper.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.cbd.int/hexo-butterfly-swiper-anzhiyu@1.0.4/lib/swiperstyle.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.cbd.int/hexo-butterfly-wowjs/lib/animate.min.css" media="print" onload="this.media='screen'"><link rel="stylesheet" href="https://cdn.cbd.int/hexo-butterfly-tag-plugins-plus@latest/lib/assets/font-awesome-animation.min.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.cbd.int/hexo-butterfly-tag-plugins-plus@latest/lib/tag_plugins.css" media="defer" onload="this.media='all'"><script src="https://cdn.cbd.int/hexo-butterfly-tag-plugins-plus@latest/lib/assets/carousel-touch.js"></script><!-- hexo injector head_end end --><meta name="generator" content="Hexo 6.2.0"><link rel="alternate" href="/atom.xml" title="晚夜微雨问海棠のBlog" type="application/atom+xml">
</head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src= "" data-lazy-src="https://img2.woyaogexing.com/2022/06/28/de1ce3dc65468fd4!400x400.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">97</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">31</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">17</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/bangumis/index.html"><i class="fa-fw fas fa-home"></i><span> 追番</span></a></div><div class="menus_item"><a class="site-page" href="/comments/"><i class="fa-fw fas fa-envelope"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 生活馆</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" target="_blank" rel="noopener" href="http://81.69.189.243:8082/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友情链接</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic1.zhimg.com%2Fv2-bde07fdceb700b45ea02f16e3bb099e7_1440w.jpg%3Fsource%3D172ae18b&amp;refer=http%3A%2F%2Fpic1.zhimg.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=auto?sec=1664442254&amp;t=5014ff2160d57c4fbfe0a74d94815bf2')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">晚夜微雨问海棠のBlog</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/bangumis/index.html"><i class="fa-fw fas fa-home"></i><span> 追番</span></a></div><div class="menus_item"><a class="site-page" href="/comments/"><i class="fa-fw fas fa-envelope"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 生活馆</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" target="_blank" rel="noopener" href="http://81.69.189.243:8082/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友情链接</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">Js对象</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-11-12T03:28:51.681Z" title="发表于 2022-11-12 11:28:51">2022-11-12</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-09-25T12:41:59.997Z" title="更新于 2022-09-25 20:41:59">2022-09-25</time></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">4.5k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>19分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="Js对象"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><div class="tip warning"><p>这是小生对 Js对象 的一些拙见,有不对之处还望评论区留言,以便及时更正</p>
</div>
<h1 id="函数编程和面向对象的实例对比"><a href="#函数编程和面向对象的实例对比" class="headerlink" title="函数编程和面向对象的实例对比"></a>函数编程和面向对象的实例对比</h1><ol>
<li><p>函数编程形式：</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//  函数编程形式</span></span><br><span class="line">    <span class="keyword">let</span> name = <span class="string">&#x27;浩果锅&#x27;</span></span><br><span class="line">    <span class="keyword">let</span> grade = [</span><br><span class="line">      &#123; <span class="attr">name</span>: <span class="string">&#x27;js&#x27;</span>, <span class="attr">score</span>: <span class="number">99</span> &#125;,</span><br><span class="line">      &#123; <span class="attr">name</span>: <span class="string">&#x27;docker&#x27;</span>, <span class="attr">score</span>: <span class="number">99</span> &#125;,</span><br><span class="line">    ]</span><br><span class="line">    <span class="keyword">function</span> <span class="title function_">average</span>(<span class="params">grade, name</span>) &#123;</span><br><span class="line">      <span class="keyword">let</span> total = grade.<span class="title function_">reduce</span>(<span class="function">(<span class="params">t, l</span>) =&gt;</span> t + l.<span class="property">score</span>, <span class="number">0</span>)</span><br><span class="line">      <span class="keyword">return</span> <span class="string">`<span class="subst">$&#123;name&#125;</span>的平均成绩是: <span class="subst">$&#123;total / grade.length&#125;</span>`</span></span><br><span class="line">    &#125;</span><br><span class="line">    <span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="title function_">average</span>(grade, name))</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
<li><p>面向对象形式：</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 面向对象形式</span></span><br><span class="line">    <span class="keyword">const</span> user = &#123;</span><br><span class="line">      <span class="attr">name</span>: <span class="string">&#x27;浩果锅&#x27;</span>,</span><br><span class="line">      <span class="attr">grade</span>: [</span><br><span class="line">        &#123; <span class="attr">name</span>: <span class="string">&#x27;js&#x27;</span>, <span class="attr">score</span>: <span class="number">99</span> &#125;,</span><br><span class="line">        &#123; <span class="attr">name</span>: <span class="string">&#x27;docker&#x27;</span>, <span class="attr">score</span>: <span class="number">99</span> &#125;,</span><br><span class="line">      ],</span><br><span class="line">      <span class="title function_">average</span>(<span class="params"></span>) &#123;</span><br><span class="line">        <span class="keyword">let</span> total = <span class="variable language_">this</span>.<span class="property">grade</span>.<span class="title function_">reduce</span>(<span class="function">(<span class="params">t, l</span>) =&gt;</span> t + l.<span class="property">score</span>, <span class="number">0</span>)</span><br><span class="line">        <span class="keyword">return</span> <span class="string">`<span class="subst">$&#123;<span class="variable language_">this</span>.name&#125;</span>的平均成绩是: <span class="subst">$&#123;total / <span class="variable language_">this</span>.grade.length&#125;</span>`</span></span><br><span class="line">      &#125;,</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="variable language_">console</span>.<span class="title function_">log</span>(user.<span class="title function_">average</span>())</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
<li><p>可以看出面向对象的形式更为简便，只要封装好一个对象，调用方法就行了。</p>
</li>
<li><p>而函数编程，就显得比较复杂，需要写很多模块，</p>
</li>
</ol>
<h1 id="属性的基本操作方法"><a href="#属性的基本操作方法" class="headerlink" title="属性的基本操作方法"></a>属性的基本操作方法</h1><ol>
<li><p>属性的读取方式</p>
<blockquote>
<p>1、推荐使用 . 语法</p>
<p>2、数组语法也可读取，一般是比较特殊的属性，使用 . 语法读取不了</p>
<p>3、遍历+数组语法，读取</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">     <span class="keyword">let</span> user = &#123;</span><br><span class="line">     	<span class="attr">name</span>: <span class="string">&#x27;浩果锅&#x27;</span>,</span><br><span class="line">       <span class="string">&#x27;my age&#x27;</span>: <span class="number">18</span>,</span><br><span class="line">     	&#125;</span><br><span class="line"></span><br><span class="line"><span class="comment">// 1.推荐使用 . 语法</span></span><br><span class="line">     <span class="variable language_">console</span>.<span class="title function_">log</span>(user.<span class="property">name</span>)</span><br><span class="line">     <span class="comment">// console.log(user.my age) 报错</span></span><br><span class="line"></span><br><span class="line">     <span class="comment">// 2.数组语法也可读取，特殊的使用中括号的形式</span></span><br><span class="line">     <span class="variable language_">console</span>.<span class="title function_">log</span>(user[<span class="string">&#x27;name&#x27;</span>])</span><br><span class="line">     <span class="variable language_">console</span>.<span class="title function_">log</span>(user[<span class="string">&#x27;my age&#x27;</span>])</span><br><span class="line"></span><br><span class="line">     <span class="comment">// 3.遍历+数组的形式</span></span><br><span class="line">     <span class="keyword">for</span> (<span class="keyword">const</span> key <span class="keyword">in</span> user) &#123;</span><br><span class="line">       <span class="variable language_">console</span>.<span class="title function_">log</span>(user[key])</span><br><span class="line">     &#125;</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
<li><p>动态的添加属性或方法</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">user.<span class="property">age</span> = <span class="number">19</span></span><br><span class="line">  user.<span class="property">get</span> = <span class="keyword">function</span> (<span class="params"></span>) &#123;</span><br><span class="line">    <span class="keyword">return</span> <span class="string">`<span class="subst">$&#123;<span class="variable language_">this</span>.name&#125;</span>的年龄是<span class="subst">$&#123;<span class="variable language_">this</span>.age&#125;</span>`</span></span><br><span class="line">  &#125;</span><br><span class="line">  <span class="variable language_">console</span>.<span class="title function_">log</span>(user.<span class="title function_">get</span>())</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
<li><p>删除对象中的属性或方法</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 5.删除对象中的属性</span></span><br><span class="line">    <span class="keyword">delete</span> user.<span class="property">age</span></span><br><span class="line">    <span class="variable language_">console</span>.<span class="title function_">log</span>(user.<span class="title function_">get</span>()) <span class="comment">// 就会获取不到 age属性了</span></span><br></pre></td></tr></table></figure>
</blockquote>
</li>
</ol>
<h1 id="对象的引用传值"><a href="#对象的引用传值" class="headerlink" title="对象的引用传值"></a>对象的引用传值</h1><ol>
<li><p>对象的传值和复制操作是不一样的，复制操作需要使用浅拷贝+深拷贝</p>
</li>
<li><p>注意：使用时要注意引用类型的特点</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> user = &#123;&#125;</span><br><span class="line">  <span class="keyword">let</span> hd = user</span><br><span class="line">  user.<span class="property">name</span> = <span class="string">&#x27;浩果锅&#x27;</span></span><br><span class="line">  <span class="comment">// 引用类型的特点，对象中声明一个属性，有人引用它，它也就可以使用这个属性</span></span><br><span class="line">  <span class="variable language_">console</span>.<span class="title function_">log</span>(hd.<span class="property">name</span>)</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 函数,传值</span></span><br><span class="line">  <span class="keyword">let</span> p = &#123; <span class="attr">name</span>: <span class="string">&#x27;后盾人&#x27;</span> &#125;</span><br><span class="line">  <span class="keyword">function</span> <span class="title function_">show</span>(<span class="params">a</span>) &#123;</span><br><span class="line">    a = a + <span class="number">100</span></span><br><span class="line">    <span class="variable language_">console</span>.<span class="title function_">log</span>(a) <span class="comment">// 内部的 a 和 外部的a 不是同一个变量，虽然名字一样</span></span><br><span class="line">  &#125;</span><br><span class="line">  <span class="keyword">let</span> a = <span class="number">1</span></span><br><span class="line">  <span class="title function_">show</span>(a)</span><br><span class="line">  <span class="variable language_">console</span>.<span class="title function_">log</span>(a)</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 赋值：</span></span><br><span class="line">  <span class="keyword">let</span> w = &#123; <span class="attr">name</span>: <span class="string">&#x27;浩果锅&#x27;</span> &#125;</span><br><span class="line">  <span class="keyword">function</span> <span class="title function_">s</span>(<span class="params">w</span>) &#123;</span><br><span class="line">    w.<span class="property">age</span> = <span class="number">18</span></span><br><span class="line">    <span class="variable language_">console</span>.<span class="title function_">log</span>(w)</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="title function_">s</span>(w)</span><br><span class="line">  <span class="variable language_">console</span>.<span class="title function_">log</span>(s)</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
</ol>
<h1 id="使用展示语法，完成参数合并"><a href="#使用展示语法，完成参数合并" class="headerlink" title="使用展示语法，完成参数合并"></a>使用展示语法，完成参数合并</h1><ol>
<li><p>```js<br>   //  展开语法 …</p>
<pre><code>  let arr = [1, 2, 3]
  let a = [...arr, 5, 6, 7]
  console.log(a)

  // 对象的引用
  let user = &#123; name: &#39;向军&#39;, age: 22 &#125;
  let hd = &#123; ...user, lang: &#39;zh&#39; &#125;
  console.log(hd)

  // 如果同名的话，传进来的值会替换掉原来的值
  function upload(params) &#123;
    let config = &#123;
      type: &#39;*.jpg,*.png&#39;,
      size: 10000,
    &#125;
    config = &#123; ...config, ...params &#125;
    console.log(config)
  &#125;
  console.log(upload(&#123; size: 99, type: &#39;*.gif&#39; &#125;))
</code></pre><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"># 结构赋值</span><br><span class="line"></span><br><span class="line">1. 对象的解构赋值：</span><br><span class="line"></span><br><span class="line">   &gt; ```js</span><br><span class="line">   &gt;       // 对象的解构赋值</span><br><span class="line">   &gt;       let user = &#123; name: &#x27;浩果锅&#x27;, age: 18 &#125;</span><br><span class="line">   &gt;       // 解构赋值</span><br><span class="line">   &gt;       let &#123; name, age &#125; = user</span><br><span class="line">   &gt;       console.log(name)</span><br></pre></td></tr></table></figure>
</li>
<li><p>函数的解构</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 函数的解构</span></span><br><span class="line"><span class="keyword">function</span> <span class="title function_">hy</span>(<span class="params"></span>) &#123;</span><br><span class="line">  <span class="keyword">return</span> &#123; <span class="attr">name1</span>: <span class="string">&#x27;浩果锅&#x27;</span>, <span class="attr">age1</span>: <span class="number">18</span> &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">let</span> &#123; name1, age1 &#125; = <span class="title function_">hy</span>()</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
<li><p>传参解构：</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 传参</span></span><br><span class="line"><span class="keyword">function</span> <span class="title function_">stu</span>(<span class="params">name, age</span>) &#123;</span><br><span class="line">  <span class="variable language_">console</span>.<span class="title function_">log</span>(name, age)</span><br><span class="line">&#125;</span><br><span class="line"><span class="title function_">stu</span>(&#123; <span class="attr">name</span>: <span class="string">&#x27;鱼妹妹&#x27;</span>, <span class="attr">age</span>: <span class="number">18</span> &#125;)</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
<li><p>解构系统函数</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 解构系统函数</span></span><br><span class="line"><span class="keyword">let</span> &#123; random &#125; = <span class="title class_">Math</span></span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="title function_">random</span>())</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
<li><p>数组解构</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 数组解构</span></span><br><span class="line"><span class="keyword">const</span> arr = [<span class="string">&#x27;浩果锅&#x27;</span>, <span class="string">&#x27;18岁&#x27;</span>]</span><br><span class="line"><span class="keyword">let</span> [, b] = arr</span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(b)</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
<li><p>对象解构的另一种方式</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 对象：</span></span><br><span class="line"><span class="keyword">const</span> p = &#123; <span class="attr">name</span>: <span class="string">&#x27;hello&#x27;</span>, <span class="attr">title</span>: <span class="string">&#x27;world&#x27;</span> &#125;</span><br><span class="line"><span class="keyword">let</span> &#123; title &#125; = p</span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(title)</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
<li><p>多层级对象解构</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="comment">// 多层次的对象解构</span></span><br><span class="line"><span class="keyword">const</span> students = &#123; <span class="attr">name2</span>: <span class="string">&#x27;鱼妹妹&#x27;</span>, <span class="attr">lesson</span>: &#123; <span class="attr">title1</span>: <span class="string">&#x27;爱听歌&#x27;</span> &#125; &#125;</span><br><span class="line"><span class="keyword">let</span> &#123;</span><br><span class="line">  name2,</span><br><span class="line">  <span class="attr">lesson</span>: &#123; title1 &#125;,</span><br><span class="line">&#125; = students</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
<li><p>解构的默认值</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 解构的默认值</span></span><br><span class="line"><span class="keyword">const</span> tt = [<span class="string">&#x27;浩果锅&#x27;</span>, <span class="string">&#x27;鱼妹妹&#x27;</span>]</span><br><span class="line"><span class="keyword">let</span> [a, d, c = <span class="string">&#x27;羊弟弟&#x27;</span>] = tt</span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(a, d, c)</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
</ol>
<h1 id="对象属性的添加和删除"><a href="#对象属性的添加和删除" class="headerlink" title="对象属性的添加和删除"></a>对象属性的添加和删除</h1><ol>
<li><p>添加：</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 添加</span></span><br><span class="line"><span class="keyword">let</span> hd = &#123;&#125;</span><br><span class="line">hd.<span class="property">name</span> = <span class="string">&#x27;浩果锅&#x27;</span></span><br><span class="line">hd[<span class="string">&#x27;age&#x27;</span>] = <span class="number">18</span></span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(hd)</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
<li><p>删除：</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 删除</span></span><br><span class="line"><span class="keyword">delete</span> hd.<span class="property">name</span></span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(hd)</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
</ol>
<h1 id="对象与原型链属性检测"><a href="#对象与原型链属性检测" class="headerlink" title="对象与原型链属性检测"></a>对象与原型链属性检测</h1><ol>
<li><p>关键字：hasOwnProperty（‘要检测的属性名’）</p>
</li>
<li><p>用于检测对象上有没有这个属性</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 检测属性:关键字,hasOwnProperty</span></span><br><span class="line">     <span class="comment">// 用于检测hd对象上有没有 name 属性</span></span><br><span class="line">     <span class="variable language_">console</span>.<span class="title function_">log</span>(hd.<span class="title function_">hasOwnProperty</span>(<span class="string">&#x27;name&#x27;</span>))</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
<li><p>关键字：Object.setPrototypeOf（设置原型）</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 为父级设置原型</span></span><br><span class="line">   <span class="title class_">Object</span>.<span class="title function_">setPrototypeOf</span>(a, b)</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
<li><p>只检测父级</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 检测父级</span></span><br><span class="line">    <span class="keyword">const</span> arr = [<span class="string">&#x27;浩果锅&#x27;</span>, <span class="string">&#x27;鱼妹妹&#x27;</span>]</span><br><span class="line">    <span class="variable language_">console</span>.<span class="title function_">log</span>(arr)</span><br><span class="line">    <span class="comment">// 检测父级</span></span><br><span class="line">    <span class="variable language_">console</span>.<span class="title function_">log</span>(arr.<span class="title function_">hasOwnProperty</span>(<span class="string">&#x27;length&#x27;</span>))</span><br><span class="line">    <span class="variable language_">console</span>.<span class="title function_">log</span>(arr.<span class="title function_">hasOwnProperty</span>(<span class="string">&#x27;length&#x27;</span>))</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
<li><p>子级父级都检测</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">     <span class="comment">// 检测父级</span></span><br><span class="line">     <span class="keyword">const</span> arr = [<span class="string">&#x27;浩果锅&#x27;</span>, <span class="string">&#x27;鱼妹妹&#x27;</span>]</span><br><span class="line">     <span class="variable language_">console</span>.<span class="title function_">log</span>(arr)</span><br><span class="line"><span class="comment">// 子级父级都检测</span></span><br><span class="line">     <span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="string">&#x27;length&#x27;</span> <span class="keyword">in</span> arr)</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
<li><p>实例：</p>
<blockquote>
<p>1、不确定什么属性或什么类型，可设置让用户传递</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 实例：</span></span><br><span class="line">  <span class="comment">// 让用户必须传递一个属性</span></span><br><span class="line">  <span class="keyword">function</span> <span class="title function_">oss</span>(<span class="params">options</span>) &#123;</span><br><span class="line">    <span class="keyword">if</span> (options.<span class="title function_">hasOwnProperty</span>(<span class="string">&#x27;host&#x27;</span>)) &#123;</span><br><span class="line">        <span class="comment">// 用户没传递就要报错</span></span><br><span class="line">      <span class="keyword">throw</span> <span class="keyword">new</span> <span class="title class_">Error</span>(<span class="string">&#x27;必须设置属性&#x27;</span>)</span><br><span class="line">    &#125;</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="title function_">oss</span>(&#123; <span class="attr">user</span>: <span class="string">&#x27;admin&#x27;</span> &#125;)</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
</ol>
<h1 id="计算属性和-assign-使用"><a href="#计算属性和-assign-使用" class="headerlink" title="计算属性和 assign 使用"></a>计算属性和 assign 使用</h1><ol>
<li><p>关键字：Object.assign对象合并</p>
</li>
<li><p>计算属性：</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> hd = &#123;&#125;</span><br><span class="line">  <span class="keyword">let</span> name = <span class="string">&#x27;title&#x27;</span></span><br><span class="line">  hd[name] = <span class="string">&#x27;浩果锅&#x27;</span></span><br><span class="line">  <span class="variable language_">console</span>.<span class="title function_">log</span>(hd.<span class="property">title</span>)</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
<li><p>对象合并：</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 数组转换为对象</span></span><br><span class="line">  <span class="comment">// Object.assign对象合并</span></span><br><span class="line">  <span class="keyword">let</span> hs = <span class="title class_">Object</span>.<span class="title function_">assign</span>(&#123; <span class="attr">a</span>: <span class="number">1</span> &#125;, &#123; <span class="attr">b</span>: <span class="number">2</span> &#125;)</span><br><span class="line">  <span class="variable language_">console</span>.<span class="title function_">log</span>(hs)</span><br><span class="line"></span><br><span class="line">  <span class="keyword">function</span> <span class="title function_">upload</span>(<span class="params">params</span>) &#123;</span><br><span class="line">    <span class="keyword">let</span> options = &#123;</span><br><span class="line">      <span class="attr">size</span>: <span class="number">1999</span>,</span><br><span class="line">    &#125;</span><br><span class="line">    options = <span class="title class_">Object</span>.<span class="title function_">assign</span>(options, params)</span><br><span class="line">    <span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="title class_">JSON</span>.<span class="title function_">stringify</span>(options, <span class="literal">null</span>, <span class="number">2</span>))</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="title function_">upload</span>(&#123; <span class="attr">size</span>: <span class="number">99</span>, <span class="attr">type</span>: <span class="string">&#x27;jpg&#x27;</span> &#125;)</span><br></pre></td></tr></table></figure></blockquote>
</li>
<li><p>计算属性名：[]</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> s1 = <span class="title class_">Symbol</span>()</span><br><span class="line"><span class="comment">// Symbol 值 作为key</span></span><br><span class="line"><span class="comment">// [] 为计算属性名</span></span><br><span class="line"><span class="keyword">const</span> obj = &#123;</span><br><span class="line">  [s1]: <span class="string">&#x27;abc&#x27;</span>,</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="遍历操作，与DOM绘制"><a href="#遍历操作，与DOM绘制" class="headerlink" title="遍历操作，与DOM绘制"></a>遍历操作，与DOM绘制</h1></li>
<li><p>DOM绘制：</p>
<blockquote>
<p>关键字：</p>
<p>1、Object.keys() 获取对象所有的名字</p>
<p>2、Object.values() 获取对象所有的值</p>
<p>3、Object.entries() 对象名和值转换为数组</p>
</blockquote>
</li>
<li><p>DOM绘制：</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// DOM 绘制</span></span><br><span class="line"> <span class="keyword">let</span> hd = &#123;</span><br><span class="line">   <span class="attr">name</span>: <span class="string">&#x27;浩果锅&#x27;</span>,</span><br><span class="line">   <span class="attr">year</span>: <span class="string">&#x27;2000&#x27;</span>,</span><br><span class="line"> &#125;</span><br><span class="line"> <span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="title class_">Object</span>.<span class="title function_">keys</span>(hd))</span><br><span class="line"> <span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="title class_">Object</span>.<span class="title function_">values</span>(hd))</span><br><span class="line"> <span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="title class_">Object</span>.<span class="title function_">entries</span>(hd))</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
<li><p>循环绘制：</p>
<blockquote>
<p>1、循环绘制  [key]   获取对象中的所有名字</p>
<p>2、for…of 默认不能操作对象，但是可以遍历绘制后的对象</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"> <span class="comment">// 循环绘制 [key]获取对象中的所有名字</span></span><br><span class="line"> <span class="keyword">for</span> (<span class="keyword">const</span> key <span class="keyword">in</span> hd) &#123;</span><br><span class="line">   <span class="variable language_">console</span>.<span class="title function_">log</span>(hd[key])</span><br><span class="line"> &#125;</span><br><span class="line"></span><br><span class="line"> <span class="comment">// for...of 默认不能操作对象，但是可以遍历绘制后的对象</span></span><br><span class="line"> <span class="keyword">for</span> (<span class="keyword">const</span> [key, value] <span class="keyword">of</span> <span class="title class_">Object</span>.<span class="title function_">keys</span>(hd)) &#123;</span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(key)</span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(value)</span><br><span class="line"> &#125;</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
</ol>
<h1 id="对象浅拷贝多种方式"><a href="#对象浅拷贝多种方式" class="headerlink" title="对象浅拷贝多种方式"></a>对象浅拷贝多种方式</h1><ol>
<li><p>浅拷贝不能进行深层次的复制</p>
</li>
<li><p>有四种方法：</p>
</li>
<li><p>方法一：</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> hd = &#123; <span class="attr">name</span>: <span class="string">&#x27;浩果锅&#x27;</span> &#125;</span><br><span class="line">   <span class="comment">// 方式1：</span></span><br><span class="line">   <span class="keyword">let</span> cms = &#123;</span><br><span class="line">     <span class="attr">name</span>: hd.<span class="property">name</span>,</span><br><span class="line">   &#125;</span><br><span class="line">   <span class="variable language_">console</span>.<span class="title function_">log</span>(cms)</span><br><span class="line">   cms.<span class="property">name</span> = <span class="string">&#x27;鱼妹妹&#x27;</span></span><br><span class="line">   <span class="variable language_">console</span>.<span class="title function_">log</span>(hd)</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
<li><p>方法二：循环复制</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> hd = &#123; <span class="attr">name</span>: <span class="string">&#x27;浩果锅&#x27;</span> &#125;</span><br><span class="line">	 <span class="comment">// 方法2:循环复制</span></span><br><span class="line">      <span class="keyword">let</span> obj = &#123;&#125;</span><br><span class="line">      <span class="keyword">for</span> (<span class="keyword">const</span> key <span class="keyword">in</span> hd) &#123;</span><br><span class="line">        obj[key] = hd[key]</span><br><span class="line">      &#125;</span><br><span class="line">      <span class="variable language_">console</span>.<span class="title function_">log</span>(hd)</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
<li><p>方法三：使用提供的接口，更方便</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> hd = &#123; <span class="attr">name</span>: <span class="string">&#x27;浩果锅&#x27;</span> &#125;</span><br><span class="line">	<span class="comment">// 方法3：使用提供的接口，更方便</span></span><br><span class="line">      <span class="keyword">let</span> option = <span class="title class_">Object</span>.<span class="title function_">assign</span>(&#123;&#125;, hd)</span><br><span class="line">      <span class="variable language_">console</span>.<span class="title function_">log</span>(option)</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
<li><p>方法四：展开语法</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> hd = &#123; <span class="attr">name</span>: <span class="string">&#x27;浩果锅&#x27;</span> &#125;</span><br><span class="line">	<span class="comment">// 方法4：展开语法</span></span><br><span class="line">      <span class="keyword">let</span> option1 = &#123; ...hd &#125;</span><br><span class="line">      <span class="variable language_">console</span>.<span class="title function_">log</span>(option1)</span><br><span class="line">      <span class="comment">// 此时就算改变内容，也不会影响到 hd 对象</span></span><br><span class="line">      option1.<span class="property">name</span> = <span class="string">&#x27;chrome&#x27;</span></span><br><span class="line">      <span class="variable language_">console</span>.<span class="title function_">log</span>(option1)</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
</ol>
<h1 id="深拷贝多层次分析"><a href="#深拷贝多层次分析" class="headerlink" title="深拷贝多层次分析"></a>深拷贝多层次分析</h1><ol>
<li><p>方法1：递归算法</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> obj = &#123;</span><br><span class="line">    <span class="attr">name</span>: <span class="string">&#x27;浩果锅&#x27;</span>,</span><br><span class="line">    <span class="attr">user</span>: &#123;</span><br><span class="line">      <span class="attr">name</span>: <span class="string">&#x27;鱼妹妹&#x27;</span>,</span><br><span class="line">    &#125;,</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="keyword">let</span> hd = &#123;</span><br><span class="line">    <span class="attr">name</span>: obj.<span class="property">name</span>,</span><br><span class="line">    <span class="attr">name</span>: obj.<span class="property">user</span>,</span><br><span class="line">  &#125;</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 方法1：递归算法</span></span><br><span class="line">  <span class="keyword">function</span> <span class="title function_">copy</span>(<span class="params">object</span>) &#123;</span><br><span class="line">    <span class="keyword">let</span> res = &#123;&#125;</span><br><span class="line">    <span class="keyword">for</span> (<span class="keyword">const</span> key <span class="keyword">in</span> object) &#123;</span><br><span class="line">      res[key] = <span class="keyword">typeof</span> object[key] == <span class="string">&#x27;object&#x27;</span> ? <span class="title function_">copy</span>(object[key]) : object[key]</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> res</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="keyword">let</span> h = <span class="title function_">copy</span>(data)</span><br><span class="line">  <span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="title class_">JSON</span>.<span class="title function_">stringify</span>(h, <span class="literal">null</span>, <span class="number">2</span>))</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
</ol>
<h1 id="使用工厂函数创建对象"><a href="#使用工厂函数创建对象" class="headerlink" title="使用工厂函数创建对象"></a>使用工厂函数创建对象</h1><ol>
<li><p>工厂函数：对函数进行统一的定制，简化代码量</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">     <span class="comment">// 工厂函数</span></span><br><span class="line">     <span class="keyword">function</span> <span class="title function_">user</span>(<span class="params">name, age</span>) &#123;</span><br><span class="line">       <span class="keyword">return</span> &#123;</span><br><span class="line">         name,</span><br><span class="line">         age,</span><br><span class="line">         <span class="title function_">show</span>(<span class="params"></span>) &#123;</span><br><span class="line">           <span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="variable language_">this</span>.<span class="property">name</span>)</span><br><span class="line">         &#125;,</span><br><span class="line">         <span class="title function_">info</span>(<span class="params"></span>) &#123;</span><br><span class="line">           <span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="string">`<span class="subst">$&#123;<span class="variable language_">this</span>.name&#125;</span>的年龄是<span class="subst">$&#123;<span class="variable language_">this</span>.age&#125;</span>`</span>)</span><br><span class="line">         &#125;,</span><br><span class="line">       &#125;</span><br><span class="line">     &#125;</span><br><span class="line"><span class="comment">// 调用</span></span><br><span class="line">     <span class="keyword">let</span> hg = <span class="title function_">user</span>(<span class="string">&#x27;浩果锅&#x27;</span>)</span><br><span class="line">     hg.<span class="property">name</span></span><br><span class="line">     <span class="keyword">let</span> list = <span class="title function_">user</span>(<span class="string">&#x27;鱼妹妹&#x27;</span>, <span class="number">22</span>)</span><br><span class="line">     list.<span class="title function_">info</span>()</span><br><span class="line">     list.<span class="title function_">show</span>()</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
</ol>
<h1 id="通过构造函数的形式创建对象"><a href="#通过构造函数的形式创建对象" class="headerlink" title="通过构造函数的形式创建对象"></a>通过构造函数的形式创建对象</h1><ol>
<li><p>注意：创建时要注意规范，首字母大写</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">     <span class="comment">// 构造函数</span></span><br><span class="line"><span class="keyword">function</span> <span class="title function_">User</span>(<span class="params">name</span>) &#123;</span><br><span class="line">       <span class="variable language_">this</span>.<span class="property">name</span> = name</span><br><span class="line">       <span class="variable language_">this</span>.<span class="property">show</span> = <span class="keyword">function</span> (<span class="params"></span>) &#123;</span><br><span class="line">         <span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="variable language_">this</span>.<span class="property">name</span>)</span><br><span class="line">       &#125;</span><br><span class="line">       <span class="comment">// return this</span></span><br><span class="line">     &#125;</span><br><span class="line">     <span class="keyword">let</span> hg = <span class="keyword">new</span> <span class="title class_">User</span>(<span class="string">&#x27;浩果锅&#x27;</span>)</span><br><span class="line">     <span class="variable language_">console</span>.<span class="title function_">log</span>(hg)</span><br><span class="line">     hg.<span class="title function_">show</span>()</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
</ol>
<h1 id="面向对象的封装与抽象"><a href="#面向对象的封装与抽象" class="headerlink" title="面向对象的封装与抽象"></a>面向对象的封装与抽象</h1><ol>
<li><p>封装：将使用的属性、函数、封装到一个函数中，但是函数外可以修改函数内的属性值</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">function</span> <span class="title function_">User</span>(<span class="params">name, age</span>) &#123;</span><br><span class="line">   <span class="variable language_">this</span>.<span class="property">name</span> = name</span><br><span class="line">   <span class="variable language_">this</span>.<span class="property">age</span> = age</span><br><span class="line">   <span class="variable language_">this</span>.<span class="property">show</span> = <span class="keyword">function</span> (<span class="params">name, age</span>) &#123;</span><br><span class="line">     <span class="variable language_">console</span>.<span class="title function_">log</span>(name, age)</span><br><span class="line">   &#125;</span><br><span class="line"> &#125;</span><br><span class="line"> <span class="keyword">let</span> hh = <span class="keyword">new</span> <span class="title class_">User</span>(<span class="string">&#x27;浩果锅&#x27;</span>)</span><br><span class="line"> hh.<span class="property">name</span>-<span class="string">&#x27;鱼妹妹&#x27;</span></span><br></pre></td></tr></table></figure>
</blockquote>
</li>
<li><p>抽象：使用闭包+作用域的特性，函数外部不能修改函数内属性的值</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 抽象，使用闭包的特性，作用域</span></span><br><span class="line"><span class="keyword">function</span> <span class="title function_">User1</span>(<span class="params">name, age</span>) &#123;</span><br><span class="line">  <span class="keyword">let</span> data = &#123; name, age &#125;</span><br><span class="line">  <span class="variable language_">this</span>.<span class="property">info</span> = <span class="keyword">function</span> (<span class="params"></span>) &#123;</span><br><span class="line">    <span class="keyword">return</span> data.<span class="property">age</span> &gt; <span class="number">50</span> ? <span class="string">&#x27;老年&#x27;</span> : <span class="string">&#x27;青年&#x27;</span></span><br><span class="line">  &#125;</span><br><span class="line">  <span class="comment">// 使用闭包的特性，内部函数可以访问外部函数</span></span><br><span class="line">  <span class="variable language_">this</span>.<span class="property">show</span> = <span class="keyword">function</span> (<span class="params">name, age</span>) &#123;</span><br><span class="line">    <span class="variable language_">console</span>.<span class="title function_">log</span>(data.<span class="property">name</span>, <span class="title function_">info</span>())</span><br><span class="line">  &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">let</span> hh1 = <span class="keyword">new</span> <span class="title class_">User1</span>(<span class="string">&#x27;浩果锅&#x27;</span>)</span><br><span class="line"><span class="comment">// 外部不能修改抽象后的属性值</span></span><br><span class="line"><span class="variable language_">this</span>.<span class="property">name</span> = <span class="string">&#x27;鱼妹妹&#x27;</span></span><br><span class="line">hh1.<span class="title function_">show</span>()</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
</ol>
<h1 id="什么是对象的属性特征"><a href="#什么是对象的属性特征" class="headerlink" title="什么是对象的属性特征"></a>什么是对象的属性特征</h1><ol>
<li><p>关键字：<em>Object.getOwnPropertyDescriptor</em>（对象名，‘属性名’）获取对象中单个属性的特征</p>
</li>
<li><p>关键字：<em>Object.getOwnPropertyDescriptors</em>（对象名）获取对象中所有属性的特征</p>
</li>
<li><p>关键字：Object.defineProperty（对象，‘属性名’）单个定义新属性，修改原属性</p>
</li>
<li><p>关键字：Object.defineProperties（对象，{}）批量定义新属性，修改原属性</p>
<blockquote>
<p>1、特征详细信息，属性</p>
<p>2、这些特征，常用于某些对象的属性不想被用户修改，可以用这些特征来控制</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">configurable</span>: <span class="literal">true</span> <span class="comment">// 是否可删除或重新配置</span></span><br><span class="line">  <span class="attr">enumerable</span>: <span class="literal">true</span>   <span class="comment">// 是否可遍历</span></span><br><span class="line">  <span class="attr">value</span>: <span class="string">&#x27;浩果锅&#x27;</span>    <span class="comment">// 属性值</span></span><br><span class="line">  <span class="attr">writable</span>: <span class="literal">true</span>    <span class="comment">// 属性可修改的</span></span><br></pre></td></tr></table></figure>
</blockquote>
</li>
<li><p>例子：</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> user = &#123;</span><br><span class="line">  <span class="attr">name</span>: <span class="string">&#x27;浩果锅&#x27;</span>,</span><br><span class="line">  <span class="attr">age</span>: <span class="number">15</span>,</span><br><span class="line">&#125;</span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="title class_">Object</span>.<span class="title function_">getOwnPropertyDescriptor</span>(user, <span class="string">&#x27;name&#x27;</span>))</span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="title class_">Object</span>.<span class="title function_">getOwnPropertyDescriptors</span>(user))</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
<li><p>灵活运用对象属性特征：</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> user = &#123;</span><br><span class="line">  <span class="attr">name</span>: <span class="string">&#x27;浩果锅&#x27;</span>,</span><br><span class="line">  <span class="attr">age</span>: <span class="number">18</span>,</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">// getOwnPropertyDescriptor获取对象中单个属性的属性值</span></span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="title class_">JSON</span>.<span class="title function_">stringify</span>(<span class="title class_">Object</span>.<span class="title function_">getOwnPropertyDescriptor</span>(user, <span class="string">&#x27;age&#x27;</span>)))</span><br><span class="line"><span class="comment">// defineProperty定义新属性，修改原属性</span></span><br><span class="line"><span class="comment">// 对象默认属性控制对象 writable，是否可修改</span></span><br><span class="line"><span class="title class_">Object</span>.<span class="title function_">defineProperty</span>(user, <span class="string">&#x27;name&#x27;</span>, &#123;</span><br><span class="line">  <span class="attr">value</span>: <span class="string">&#x27;鱼妹妹&#x27;</span>,</span><br><span class="line">  <span class="attr">writable</span>: <span class="literal">true</span>, <span class="comment">// 是否可修改</span></span><br><span class="line">  <span class="attr">enumerable</span>: <span class="literal">true</span>, <span class="comment">// 是否可遍历</span></span><br><span class="line">  <span class="attr">configurable</span>: <span class="literal">true</span>, <span class="comment">// 是否可删除</span></span><br><span class="line">&#125;)</span><br><span class="line"><span class="comment">// 对多个属性进行配置</span></span><br><span class="line"><span class="title class_">Object</span>.<span class="title function_">defineProperties</span>(user, &#123;</span><br><span class="line">  <span class="attr">name</span>: &#123;</span><br><span class="line">    <span class="attr">value</span>: <span class="string">&#x27;鱼妹妹&#x27;</span>,</span><br><span class="line">    <span class="attr">writable</span>: <span class="literal">true</span>, <span class="comment">// 是否可修改</span></span><br><span class="line">    <span class="attr">enumerable</span>: <span class="literal">true</span>, <span class="comment">// 是否可遍历</span></span><br><span class="line">    <span class="attr">configurable</span>: <span class="literal">true</span>, <span class="comment">// 是否可删除</span></span><br><span class="line">  &#125;,</span><br><span class="line">  <span class="attr">age</span>: &#123;</span><br><span class="line">    <span class="attr">value</span>: <span class="string">&#x27;鱼妹妹&#x27;</span>,</span><br><span class="line">    <span class="attr">writable</span>: <span class="literal">true</span>, <span class="comment">// 是否可修改</span></span><br><span class="line">    <span class="attr">enumerable</span>: <span class="literal">true</span>, <span class="comment">// 是否可遍历</span></span><br><span class="line">    <span class="attr">configurable</span>: <span class="literal">true</span>, <span class="comment">// 是否可删除</span></span><br><span class="line">  &#125;,</span><br><span class="line">&#125;)</span><br><span class="line"></span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(user.<span class="property">name</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment">// 遍历</span></span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="title class_">Object</span>.<span class="title function_">keys</span>(user))</span><br><span class="line"></span><br><span class="line"><span class="comment">// 删除</span></span><br><span class="line"><span class="keyword">delete</span> user.<span class="property">name</span></span><br></pre></td></tr></table></figure>
</blockquote>
</li>
</ol>
<h1 id="对象中-API-的操作"><a href="#对象中-API-的操作" class="headerlink" title="对象中 API 的操作"></a>对象中 API 的操作</h1><h2 id="不允许向对象中添加属性-API"><a href="#不允许向对象中添加属性-API" class="headerlink" title="不允许向对象中添加属性 API"></a>不允许向对象中添加属性 API</h2><ol>
<li><p>关键字：Object.preventExtensions（对象）不允许想对象中添加属性</p>
</li>
<li><p>关键字：Object.isExtensible（对象）检测该对象是否可添加，返回布尔值 ，常用于判断</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">//  严格模式</span></span><br><span class="line"><span class="string">&#x27;user strict&#x27;</span></span><br><span class="line"><span class="keyword">const</span> user = &#123;</span><br><span class="line">  <span class="attr">name</span>: <span class="string">&#x27;浩果锅&#x27;</span>,</span><br><span class="line">  <span class="attr">age</span>: <span class="number">18</span>,</span><br><span class="line">&#125;</span><br><span class="line"><span class="comment">// preventExtensions:表示不能像对象中添加属性</span></span><br><span class="line"><span class="title class_">Object</span>.<span class="title function_">preventExtensions</span>(user)</span><br><span class="line"><span class="comment">// 判断方法，如果为真则可以添加</span></span><br><span class="line"><span class="keyword">if</span> (<span class="title class_">Object</span>.<span class="title function_">isExtensible</span>(user)) &#123;</span><br><span class="line">  user.<span class="property">site</span> = <span class="string">&#x27;鱼妹妹&#x27;</span></span><br><span class="line">  <span class="variable language_">console</span>.<span class="title function_">log</span>(user)</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
</ol>
<h2 id="封闭对象的-API-操作"><a href="#封闭对象的-API-操作" class="headerlink" title="封闭对象的 API 操作"></a>封闭对象的 API 操作</h2><ol>
<li><p>关键字：Object.seal(对象名) 封闭对象</p>
</li>
<li><p>关键字：Object.isSealed(对象名) 对象是否封闭，返回布尔值，常用于判断</p>
</li>
<li><p>作用：</p>
<blockquote>
<p>1、不能添加属性</p>
<p>2、不能删除属性</p>
<p>3、不能定制属性</p>
</blockquote>
</li>
<li><p>使用场景：当需要对，对象进行保护不想被随意修改的时候，可用</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 严格模式</span></span><br><span class="line">  <span class="string">&#x27;user strict&#x27;</span></span><br><span class="line">  <span class="keyword">const</span> user = &#123;</span><br><span class="line">    <span class="attr">name</span>: <span class="string">&#x27;浩果锅&#x27;</span>,</span><br><span class="line">    <span class="attr">age</span>: <span class="number">18</span>,</span><br><span class="line">  &#125;</span><br><span class="line">  <span class="comment">// 封闭对象</span></span><br><span class="line">  <span class="title class_">Object</span>.<span class="title function_">seal</span>(user)</span><br><span class="line"></span><br><span class="line">  <span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="title class_">JSON</span>.<span class="title function_">stringify</span>(<span class="title class_">Object</span>.<span class="title function_">getOwnPropertyDescriptors</span>(user), <span class="literal">null</span>, <span class="number">2</span>))</span><br><span class="line">  <span class="comment">// 因为，对象被封闭，所以不能添加对象</span></span><br><span class="line">  user.<span class="property">site</span> = <span class="string">&#x27;鱼妹妹&#x27;</span> <span class="comment">// 报错</span></span><br><span class="line"></span><br><span class="line">  <span class="comment">// 判断对象是否处于封闭状态，常用于判断</span></span><br><span class="line">  <span class="title class_">Object</span>.<span class="title function_">isSealed</span>(user)</span><br><span class="line"></span><br><span class="line">  <span class="comment">// 当对象不封闭的时候，添加属性</span></span><br><span class="line">  <span class="keyword">if</span> (!<span class="title class_">Object</span>.<span class="title function_">isSealed</span>(user)) &#123;</span><br><span class="line">    user.<span class="property">site</span> = <span class="string">&#x27;鱼妹妹&#x27;</span> <span class="comment">// 添加属性</span></span><br><span class="line">  &#125;</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
</ol>
<h2 id="冻结对象-API-特性"><a href="#冻结对象-API-特性" class="headerlink" title="冻结对象 API 特性"></a>冻结对象 API 特性</h2><ol>
<li><p>关键字：Object.freeze(对象) 冻结对象</p>
</li>
<li><p>关键字：Object.isFrozen(对象) 检测对象是否是冻结状态，返回布尔值</p>
</li>
<li><p>作用和使用场景：</p>
<blockquote>
<p>1、不能添加属性</p>
<p>2、不能删除属性</p>
<p>3、不能修改属性</p>
<p>4、对象中的数据是可以使用的，但是不会由有意还是无意的修改数据</p>
</blockquote>
</li>
<li><p>```js</p>
<pre><code>  // 严格模式
  &#39;user strict&#39;
  const user = &#123;
    name: &#39;浩果锅&#39;,
    age: 18,
  &#125;
  // 冻结对象
  Object.freeze(user)
  console.log(JSON.stringify(Object.getOwnPropertyDescriptors(user), null, 2))

  // 不能添加属性
  user.site = &#39;鱼妹妹&#39; // 报错

  // 不能删除属性
  delete user.name

  // 不能修改属性
  user.name = &#39;羊弟弟&#39;

  // 检测对象是否是冻结状态,返回布尔
  Object.isFrozen(user)
</code></pre><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"># 访问器的使用</span><br><span class="line"></span><br><span class="line">## 使用访问器保护数据</span><br><span class="line"></span><br><span class="line">1. 设置访问器：set,必须有且只有一个参数</span><br><span class="line"></span><br><span class="line">2. 获取访问器：get</span><br><span class="line"></span><br><span class="line">3. 使用场景：</span><br><span class="line"></span><br><span class="line">   &gt; 1、在方法前加 set 进行访问调用的时的设置</span><br><span class="line">   &gt;</span><br><span class="line">   &gt; 2、获取方法前加 get 进行调用后获取访问</span><br><span class="line">   &gt;</span><br><span class="line">   &gt; 3、例如：</span><br><span class="line">   &gt;</span><br><span class="line">   &gt; （1）加了 set 访问器的函数，可用于设置访问的条件，系统自动判断，如果不符合条件就抛出错误</span><br><span class="line"></span><br><span class="line">4. 实例</span><br><span class="line"></span><br><span class="line">   &gt; ```js</span><br><span class="line">   &gt;       // 严格模式</span><br><span class="line">   &gt;       &#x27;use strict&#x27;</span><br><span class="line">   &gt;       const user = &#123;</span><br><span class="line">   &gt;         data: &#123; name: &#x27;浩果锅&#x27;, age: 18 &#125;,</span><br><span class="line">   &gt;         // 设置访问器</span><br><span class="line">   &gt;         set setAge(value) &#123;</span><br><span class="line">   &gt;           if (typeof value == &#x27;number&#x27; || value &lt; 10 || value &gt; 100) &#123;</span><br><span class="line">   &gt;             throw new Error(&#x27;年龄设置错误&#x27;)</span><br><span class="line">   &gt;           &#125;</span><br><span class="line">   &gt;           this.data.age = value</span><br><span class="line">   &gt;         &#125;,</span><br><span class="line">   &gt;         // 获取访问器</span><br><span class="line">   &gt;         get getAge() &#123;</span><br><span class="line">   &gt;           console.log(&#x27;get...&#x27;)</span><br><span class="line">   &gt;           return this.data.age</span><br><span class="line">   &gt;         &#125;,</span><br><span class="line">   &gt;       &#125;</span><br><span class="line">   &gt;       // 访问</span><br><span class="line">   &gt;       user.setAge = 999</span><br><span class="line">   &gt;       // 获取</span><br><span class="line">   &gt;       console.log(user.getAge)</span><br><span class="line">   &gt;       // user.age = 100</span><br></pre></td></tr></table></figure>
</li>
</ol>
<p>5.</p>
<h2 id="访问器伪造属性操作"><a href="#访问器伪造属性操作" class="headerlink" title="访问器伪造属性操作"></a>访问器伪造属性操作</h2><ol>
<li>```js<pre><code>  // 严格模式
  &#39;use strict&#39;
  const lesson = &#123;
    lists: [
      &#123; name: &#39;js&#39;, price: 100 &#125;,
      &#123; name: &#39;mysql&#39;, price: 100 &#125;,
      &#123; name: &#39;vue.js&#39;, price: 100 &#125;,
    ],
    get total() &#123;
      return this.lists.reduce((t, l) =&gt; t + l.price, 0)
    &#125;,
  &#125;
  console.log(lesson.total)
  lesson.total = 100
  console.log(lesson.total)
</code></pre><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">2.</span><br><span class="line"></span><br><span class="line">## 使用访问器批量设置属性</span><br><span class="line"></span><br><span class="line">1. ```js</span><br><span class="line">         // 严格模式</span><br><span class="line">         &#x27;use strict&#x27;</span><br><span class="line">         const web = &#123;</span><br><span class="line">           name: &#x27;晚夜微雨问海棠&#x27;,</span><br><span class="line">           url: &#x27;浩果锅&#x27;,</span><br><span class="line">           get site() &#123;</span><br><span class="line">             return `$&#123;this.name&#125;的网址是$&#123;this.url&#125;`</span><br><span class="line">           &#125;,</span><br><span class="line">           set site(value) &#123;</span><br><span class="line">             ;[this.name, this.url] = value.split(&#x27;,&#x27;)</span><br><span class="line">           &#125;,</span><br><span class="line">         &#125;</span><br><span class="line">         web.site = &#x27;鱼妹妹,喜欢浩果锅&#x27;</span><br><span class="line">         console.log(web.url)</span><br><span class="line">         console.log(web.site)</span><br></pre></td></tr></table></figure>
</li>
</ol>
<h1 id="Token的读写处理"><a href="#Token的读写处理" class="headerlink" title="Token的读写处理"></a>Token的读写处理</h1><ol>
<li>```js<pre><code>  const Request = &#123;
    set token(content) &#123;
      localStorage.setItem(&#39;token&#39;, content)
    &#125;,
    get token() &#123;
      let token = localStorage.getItem(&#39;token&#39;, content)
      if (!token) &#123;
        alert(&#39;请登录&#39;)
      &#125;
      return token
    &#125;,
  &#125;
  Request.token = &#39;123135351131351853sd&#39;
  console.log(Request.token)
</code></pre><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"># 访问器的优先级</span><br><span class="line"></span><br><span class="line">1. 访问器的优先级高于普通操作模式</span><br><span class="line"></span><br><span class="line">   &gt; ```js</span><br><span class="line">   &gt;       // 严格模式</span><br><span class="line">   &gt;       &#x27;use strict&#x27;</span><br><span class="line">   &gt;       const user = &#123;</span><br><span class="line">   &gt;         date: &#123; name: &#x27;晚夜微雨问海棠&#x27;, age &#125;,</span><br><span class="line">   &gt;         set name(value) &#123;</span><br><span class="line">   &gt;           console.log(value + &#x27;-鱼妹妹&#x27;)</span><br><span class="line">   &gt;         &#125;,</span><br><span class="line">   &gt;         get name() &#123;</span><br><span class="line">   &gt;           return this.name</span><br><span class="line">   &gt;         &#125;,</span><br><span class="line">   &gt;       &#125;</span><br><span class="line">   &gt;       user.name = &#x27;浩果锅&#x27;</span><br><span class="line">   &gt;       console.log(user.name)</span><br></pre></td></tr></table></figure>
</li>
</ol>
<h1 id="构造函数与class语法糖中的访问器"><a href="#构造函数与class语法糖中的访问器" class="headerlink" title="构造函数与class语法糖中的访问器"></a>构造函数与class语法糖中的访问器</h1><ol>
<li><p>构造函数</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 严格模式</span></span><br><span class="line"><span class="meta">&#x27;use strict&#x27;</span></span><br><span class="line"><span class="keyword">function</span> <span class="title function_">User</span>(<span class="params">name, age</span>) &#123;</span><br><span class="line">  <span class="comment">// 定义为私有属性</span></span><br><span class="line">  <span class="keyword">let</span> data = &#123; name, age &#125;</span><br><span class="line">  <span class="comment">// 定义对象特征</span></span><br><span class="line">  <span class="title class_">Object</span>.<span class="title function_">defineProperties</span>(<span class="variable language_">this</span>, &#123;</span><br><span class="line">    <span class="attr">name</span>: &#123;</span><br><span class="line">      <span class="title function_">get</span>(<span class="params"></span>) &#123;</span><br><span class="line">        <span class="keyword">return</span> data.<span class="property">name</span></span><br><span class="line">      &#125;,</span><br><span class="line">      <span class="title function_">set</span>(<span class="params">value</span>) &#123;</span><br><span class="line">        <span class="keyword">if</span> (value.<span class="title function_">trim</span>() == <span class="string">&#x27;&#x27;</span> || value.<span class="property">length</span> &gt; <span class="number">20</span>) &#123;</span><br><span class="line">          <span class="comment">// 抛出错误</span></span><br><span class="line">          <span class="keyword">throw</span> <span class="keyword">new</span> <span class="title class_">Error</span>(<span class="string">&#x27;用户名不合法&#x27;</span>)</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="comment">// 使用闭包特性，就可以访问到上一级的数据了</span></span><br><span class="line">        data.<span class="property">name</span> = value</span><br><span class="line">      &#125;,</span><br><span class="line">    &#125;,</span><br><span class="line">    <span class="attr">age</span>: &#123;</span><br><span class="line">      <span class="title function_">get</span>(<span class="params"></span>) &#123;</span><br><span class="line">        <span class="keyword">return</span> data.<span class="property">age</span></span><br><span class="line">      &#125;,</span><br><span class="line">      <span class="title function_">set</span>(<span class="params">value</span>) &#123;</span><br><span class="line">        <span class="comment">// 使用闭包特性，就可以访问到上一级的数据了</span></span><br><span class="line">        data.<span class="property">age</span> = value</span><br><span class="line">      &#125;,</span><br><span class="line">    &#125;,</span><br><span class="line">  &#125;)</span><br><span class="line">&#125;</span><br><span class="line"><span class="keyword">let</span> hg = <span class="keyword">new</span> <span class="title class_">User</span>(<span class="string">&#x27;浩果锅&#x27;</span>, <span class="number">19</span>)</span><br><span class="line">hg.<span class="property">name</span> = <span class="string">&#x27;鱼妹妹&#x27;</span></span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(hg)</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
</ol>
<h1 id="什么是Proxy-代理拦截"><a href="#什么是Proxy-代理拦截" class="headerlink" title="什么是Proxy 代理拦截"></a>什么是Proxy 代理拦截</h1><ol>
<li><p>实例化一个代理对象，</p>
</li>
<li><p>const proxy = new Proxy(要代理的对象，{进行配置})</p>
</li>
<li><p>注意：get 获取有两个参数</p>
</li>
<li><p>set 设置有三个参数</p>
<blockquote>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">// 严格模式</span></span><br><span class="line"><span class="meta">&#x27;use strict&#x27;</span></span><br><span class="line"><span class="keyword">const</span> hg = &#123; <span class="attr">name</span>: <span class="string">&#x27;浩果锅&#x27;</span> &#125;</span><br><span class="line"><span class="comment">// 创建代理，代理对象 hg</span></span><br><span class="line"><span class="keyword">const</span> proxy = <span class="keyword">new</span> <span class="title class_">Proxy</span>(hg, &#123;</span><br><span class="line">  <span class="comment">// 获取,有两个参数</span></span><br><span class="line">  <span class="title function_">get</span>(<span class="params">obj, property</span>) &#123;</span><br><span class="line">    <span class="variable language_">console</span>.<span class="title function_">log</span>(property)</span><br><span class="line">    <span class="keyword">return</span> obj[property]</span><br><span class="line">  &#125;,</span><br><span class="line">  <span class="comment">// 设置，有三个参数</span></span><br><span class="line">  <span class="title function_">set</span>(<span class="params">obj, property, value</span>) &#123;</span><br><span class="line">    obj[property] = value</span><br><span class="line">    <span class="keyword">return</span> <span class="literal">true</span></span><br><span class="line">  &#125;,</span><br><span class="line">&#125;)</span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(proxy.<span class="property">name</span>)</span><br><span class="line">proxy.<span class="property">name</span> = <span class="string">&#x27;浩果锅&#x27;</span></span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(proxy.<span class="property">name</span>)</span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(proxy)</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
</ol>
<h1 id="使用代理控制函数"><a href="#使用代理控制函数" class="headerlink" title="使用代理控制函数"></a>使用代理控制函数</h1><ol>
<li>```js<pre><code>  // 严格模式
  function factorial(num) &#123;
    return (num = 1 ? 1 : num * factorial(num - 1))
  &#125;
  let proxy = new Proxy(factorial, &#123;
    // args:参数
    // obj:上下文
    // func:原函数
    apply(func, obj, args) &#123;
      console.log(func)
    &#125;,
  &#125;)
  proxy.apply(&#123;&#125;, [5])
</code></pre><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"># vue 数据绑定的容器更新</span><br><span class="line"></span><br><span class="line">1. 使用代理来写，没写完….</span><br><span class="line"></span><br><span class="line">2. ```js</span><br><span class="line">       // 构造函数</span><br><span class="line">         function View() &#123;</span><br><span class="line">           // 代理</span><br><span class="line">           let proxy = new Proxy(</span><br><span class="line">             &#123;&#125;,</span><br><span class="line">             &#123;</span><br><span class="line">               // 获取数据的方法</span><br><span class="line">               get(obj, property) &#123;&#125;,</span><br><span class="line">               // 设置数据的方法</span><br><span class="line">               set(obj, property, value) &#123;</span><br><span class="line">                 console.log(value)</span><br><span class="line">               &#125;,</span><br><span class="line">             &#125;</span><br><span class="line">           )</span><br><span class="line">           // 定义一个方法</span><br><span class="line">           this.init = function () &#123;</span><br><span class="line">             const els = document.querySelectorAll(&#x27;[v-model]&#x27;)</span><br><span class="line">             els.forEach((item) =&gt; &#123;</span><br><span class="line">               item.addEventListener(&#x27;keyup&#x27;, function (e) &#123;</span><br><span class="line">                 proxy[this.getAttribute(&#x27;v-model&#x27;)] = this.value</span><br><span class="line">               &#125;)</span><br><span class="line">             &#125;)</span><br><span class="line">           &#125;</span><br><span class="line">         &#125;</span><br><span class="line">         new View().init()</span><br></pre></td></tr></table></figure>
</li>
</ol>
<p>3.</p>
<h1 id="json数据解决什么问题"><a href="#json数据解决什么问题" class="headerlink" title="json数据解决什么问题"></a>json数据解决什么问题</h1><ol>
<li><p>配置项</p>
</li>
<li><p>多语言数据的传递更方便，数据通用</p>
</li>
<li><p>对象或数组，转换为 json</p>
<blockquote>
<p>1、关键字：JSON.stringify（对象或数组）</p>
<p>2、参数：</p>
<p>（1）要转换的 js 对象</p>
<p>（2）要保留那些属性，以数组的形式可以为 null</p>
<p>（3）缩进tab 的个数，也就是 json 格式</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> json = <span class="title class_">JSON</span>.<span class="title function_">stringify</span>(data, <span class="literal">null</span>, <span class="number">2</span>)</span><br><span class="line">   <span class="keyword">let</span> j = <span class="title class_">JSON</span>.<span class="title function_">stringify</span>(data, [name, title], <span class="number">2</span>)</span><br><span class="line">   <span class="variable language_">console</span>.<span class="title function_">log</span>(json)</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
<li><p>json 转换为 对象或数组</p>
<blockquote>
<p>1、关键字：JSON.parse（json）</p>
<p>2、参数：</p>
<p>（1）要转换为 js 对象或数组的 json</p>
<p>（2）转换的格式为箭头函数</p>
<figure class="highlight js"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">let</span> p = <span class="title class_">JSON</span>.<span class="title function_">parse</span>(json, <span class="function">(<span class="params">key, value</span>) =&gt;</span> &#123;</span><br><span class="line">     <span class="variable language_">console</span>.<span class="title function_">log</span>(value)</span><br><span class="line">   &#125;)</span><br><span class="line">   <span class="variable language_">console</span>.<span class="title function_">log</span>(p.<span class="property">name</span>)</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
</ol>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="http://example.com">晚夜微雨问海棠</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="http://example.com/posts/2f85c503.html">http://example.com/posts/2f85c503.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://example.com" target="_blank">晚夜微雨问海棠のBlog</a>！</span></div></div><div class="tag_share"><div class="post_share"><div class="social-share" data-image="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic1.zhimg.com%2Fv2-bde07fdceb700b45ea02f16e3bb099e7_1440w.jpg%3Fsource%3D172ae18b&amp;refer=http%3A%2F%2Fpic1.zhimg.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=auto?sec=1664442254&amp;t=5014ff2160d57c4fbfe0a74d94815bf2" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button"><i class="fas fa-qrcode"></i> 打赏</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="https://s1.ax1x.com/2022/11/15/zE9P7d.jpg" target="_blank"><img class="post-qr-code-img" src= "" data-lazy-src="https://s1.ax1x.com/2022/11/15/zE9P7d.jpg" alt="微信"/></a><div class="post-qr-code-desc">微信</div></li><li class="reward-item"><a href="https://s1.ax1x.com/2022/11/15/zE9ung.jpg" target="_blank"><img class="post-qr-code-img" src= "" data-lazy-src="https://s1.ax1x.com/2022/11/15/zE9ung.jpg" alt="支付宝"/></a><div class="post-qr-code-desc">支付宝</div></li></ul></div></div><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/posts/257a05e9.html" title="JavaScript 常见问题"><img class="cover" src= "" data-lazy-src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic1.zhimg.com%2Fv2-bde07fdceb700b45ea02f16e3bb099e7_1440w.jpg%3Fsource%3D172ae18b&refer=http%3A%2F%2Fpic1.zhimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1664442254&t=5014ff2160d57c4fbfe0a74d94815bf2" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-11-12</div><div class="title">JavaScript 常见问题</div></div></a></div><div><a href="/posts/b4825020.html" title="Js高级"><img class="cover" src= "" data-lazy-src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic1.zhimg.com%2Fv2-bde07fdceb700b45ea02f16e3bb099e7_1440w.jpg%3Fsource%3D172ae18b&refer=http%3A%2F%2Fpic1.zhimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1664442254&t=5014ff2160d57c4fbfe0a74d94815bf2" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-11-12</div><div class="title">Js高级</div></div></a></div><div><a href="/posts/4ba8693a.html" title="Js原型与继承"><img class="cover" src= "" data-lazy-src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic1.zhimg.com%2Fv2-bde07fdceb700b45ea02f16e3bb099e7_1440w.jpg%3Fsource%3D172ae18b&refer=http%3A%2F%2Fpic1.zhimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1664442254&t=5014ff2160d57c4fbfe0a74d94815bf2" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-11-12</div><div class="title">Js原型与继承</div></div></a></div><div><a href="/posts/91e69759.html" title="Js基础"><img class="cover" src= "" data-lazy-src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic1.zhimg.com%2Fv2-bde07fdceb700b45ea02f16e3bb099e7_1440w.jpg%3Fsource%3D172ae18b&refer=http%3A%2F%2Fpic1.zhimg.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=auto?sec=1664442254&t=5014ff2160d57c4fbfe0a74d94815bf2" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-11-12</div><div class="title">Js基础</div></div></a></div></div></div><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div class="vcomment" id="vcomment"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content is-expand"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%87%BD%E6%95%B0%E7%BC%96%E7%A8%8B%E5%92%8C%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1%E7%9A%84%E5%AE%9E%E4%BE%8B%E5%AF%B9%E6%AF%94"><span class="toc-number">1.</span> <span class="toc-text">函数编程和面向对象的实例对比</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%B1%9E%E6%80%A7%E7%9A%84%E5%9F%BA%E6%9C%AC%E6%93%8D%E4%BD%9C%E6%96%B9%E6%B3%95"><span class="toc-number">2.</span> <span class="toc-text">属性的基本操作方法</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%AF%B9%E8%B1%A1%E7%9A%84%E5%BC%95%E7%94%A8%E4%BC%A0%E5%80%BC"><span class="toc-number">3.</span> <span class="toc-text">对象的引用传值</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%BD%BF%E7%94%A8%E5%B1%95%E7%A4%BA%E8%AF%AD%E6%B3%95%EF%BC%8C%E5%AE%8C%E6%88%90%E5%8F%82%E6%95%B0%E5%90%88%E5%B9%B6"><span class="toc-number">4.</span> <span class="toc-text">使用展示语法，完成参数合并</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%AF%B9%E8%B1%A1%E5%B1%9E%E6%80%A7%E7%9A%84%E6%B7%BB%E5%8A%A0%E5%92%8C%E5%88%A0%E9%99%A4"><span class="toc-number">5.</span> <span class="toc-text">对象属性的添加和删除</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%AF%B9%E8%B1%A1%E4%B8%8E%E5%8E%9F%E5%9E%8B%E9%93%BE%E5%B1%9E%E6%80%A7%E6%A3%80%E6%B5%8B"><span class="toc-number">6.</span> <span class="toc-text">对象与原型链属性检测</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E8%AE%A1%E7%AE%97%E5%B1%9E%E6%80%A7%E5%92%8C-assign-%E4%BD%BF%E7%94%A8"><span class="toc-number">7.</span> <span class="toc-text">计算属性和 assign 使用</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E9%81%8D%E5%8E%86%E6%93%8D%E4%BD%9C%EF%BC%8C%E4%B8%8EDOM%E7%BB%98%E5%88%B6"><span class="toc-number">8.</span> <span class="toc-text">遍历操作，与DOM绘制</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%AF%B9%E8%B1%A1%E6%B5%85%E6%8B%B7%E8%B4%9D%E5%A4%9A%E7%A7%8D%E6%96%B9%E5%BC%8F"><span class="toc-number">9.</span> <span class="toc-text">对象浅拷贝多种方式</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E6%B7%B1%E6%8B%B7%E8%B4%9D%E5%A4%9A%E5%B1%82%E6%AC%A1%E5%88%86%E6%9E%90"><span class="toc-number">10.</span> <span class="toc-text">深拷贝多层次分析</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%BD%BF%E7%94%A8%E5%B7%A5%E5%8E%82%E5%87%BD%E6%95%B0%E5%88%9B%E5%BB%BA%E5%AF%B9%E8%B1%A1"><span class="toc-number">11.</span> <span class="toc-text">使用工厂函数创建对象</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E9%80%9A%E8%BF%87%E6%9E%84%E9%80%A0%E5%87%BD%E6%95%B0%E7%9A%84%E5%BD%A2%E5%BC%8F%E5%88%9B%E5%BB%BA%E5%AF%B9%E8%B1%A1"><span class="toc-number">12.</span> <span class="toc-text">通过构造函数的形式创建对象</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E9%9D%A2%E5%90%91%E5%AF%B9%E8%B1%A1%E7%9A%84%E5%B0%81%E8%A3%85%E4%B8%8E%E6%8A%BD%E8%B1%A1"><span class="toc-number">13.</span> <span class="toc-text">面向对象的封装与抽象</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%BB%80%E4%B9%88%E6%98%AF%E5%AF%B9%E8%B1%A1%E7%9A%84%E5%B1%9E%E6%80%A7%E7%89%B9%E5%BE%81"><span class="toc-number">14.</span> <span class="toc-text">什么是对象的属性特征</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E5%AF%B9%E8%B1%A1%E4%B8%AD-API-%E7%9A%84%E6%93%8D%E4%BD%9C"><span class="toc-number">15.</span> <span class="toc-text">对象中 API 的操作</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%8D%E5%85%81%E8%AE%B8%E5%90%91%E5%AF%B9%E8%B1%A1%E4%B8%AD%E6%B7%BB%E5%8A%A0%E5%B1%9E%E6%80%A7-API"><span class="toc-number">15.1.</span> <span class="toc-text">不允许向对象中添加属性 API</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%B0%81%E9%97%AD%E5%AF%B9%E8%B1%A1%E7%9A%84-API-%E6%93%8D%E4%BD%9C"><span class="toc-number">15.2.</span> <span class="toc-text">封闭对象的 API 操作</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%86%BB%E7%BB%93%E5%AF%B9%E8%B1%A1-API-%E7%89%B9%E6%80%A7"><span class="toc-number">15.3.</span> <span class="toc-text">冻结对象 API 特性</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E8%AE%BF%E9%97%AE%E5%99%A8%E4%BC%AA%E9%80%A0%E5%B1%9E%E6%80%A7%E6%93%8D%E4%BD%9C"><span class="toc-number">15.4.</span> <span class="toc-text">访问器伪造属性操作</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#Token%E7%9A%84%E8%AF%BB%E5%86%99%E5%A4%84%E7%90%86"><span class="toc-number">16.</span> <span class="toc-text">Token的读写处理</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E6%9E%84%E9%80%A0%E5%87%BD%E6%95%B0%E4%B8%8Eclass%E8%AF%AD%E6%B3%95%E7%B3%96%E4%B8%AD%E7%9A%84%E8%AE%BF%E9%97%AE%E5%99%A8"><span class="toc-number">17.</span> <span class="toc-text">构造函数与class语法糖中的访问器</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%BB%80%E4%B9%88%E6%98%AFProxy-%E4%BB%A3%E7%90%86%E6%8B%A6%E6%88%AA"><span class="toc-number">18.</span> <span class="toc-text">什么是Proxy 代理拦截</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#%E4%BD%BF%E7%94%A8%E4%BB%A3%E7%90%86%E6%8E%A7%E5%88%B6%E5%87%BD%E6%95%B0"><span class="toc-number">19.</span> <span class="toc-text">使用代理控制函数</span></a></li><li class="toc-item toc-level-1"><a class="toc-link" href="#json%E6%95%B0%E6%8D%AE%E8%A7%A3%E5%86%B3%E4%BB%80%E4%B9%88%E9%97%AE%E9%A2%98"><span class="toc-number">20.</span> <span class="toc-text">json数据解决什么问题</span></a></li></ol></div></div></div></div></main><footer id="footer" style="background-image: url('https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic1.zhimg.com%2Fv2-bde07fdceb700b45ea02f16e3bb099e7_1440w.jpg%3Fsource%3D172ae18b&amp;refer=http%3A%2F%2Fpic1.zhimg.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=auto?sec=1664442254&amp;t=5014ff2160d57c4fbfe0a74d94815bf2')"><div id="footer-wrap"><div class="copyright">&copy;2022 - 2023 By 晚夜微雨问海棠</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">繁</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="chat_btn" type="button" title="聊天"><i class="fas fa-sms"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div></div></div><div id="search-mask"></div></div><div id="rightMenu"><div class="rightMenu-group rightMenu-small"><div class="rightMenu-item" id="menu-backward"><i class="fa-solid fa-arrow-left"></i></div><div class="rightMenu-item" id="menu-forward"><i class="fa-solid fa-arrow-right"></i></div><div class="rightMenu-item" id="menu-refresh"><i class="fa-solid fa-arrow-rotate-right"></i></div><div class="rightMenu-item" id="menu-home"><i class="fa-solid fa-house"></i></div></div><div class="rightMenu-group rightMenu-line rightMenuOther"><a class="rightMenu-item menu-link" href="/archives/"><i class="fa-solid fa-archive"></i><span>文章归档</span></a><a class="rightMenu-item menu-link" href="/categories/"><i class="fa-solid fa-folder-open"></i><span>文章分类</span></a><a class="rightMenu-item menu-link" href="/tags/"><i class="fa-solid fa-tags"></i><span>文章标签</span></a></div><div class="rightMenu-group rightMenu-line rightMenuNormal"><div class="rightMenu-item" id="menu-translate"><i class="fa-solid fa-earth-asia"></i><span>繁简切换</span></div><div class="rightMenu-item" id="menu-darkmode"><i class="fa-solid fa-moon"></i><span>切换模式</span></div></div></div><div id="rightmenu-mask"></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script src="https://cdn.jsdelivr.net/npm/node-snackbar/dist/snackbar.min.js"></script><script src="/js/search/local-search.js"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"><script>(() => {
  const $mermaidWrap = document.querySelectorAll('#article-container .mermaid-wrap')
  if ($mermaidWrap.length) {
    window.runMermaid = () => {
      window.loadMermaid = true
      const theme = document.documentElement.getAttribute('data-theme') === 'dark' ? 'dark' : 'default'

      Array.from($mermaidWrap).forEach((item, index) => {
        const mermaidSrc = item.firstElementChild
        const mermaidThemeConfig = '%%{init:{ \'theme\':\'' + theme + '\'}}%%\n'
        const mermaidID = 'mermaid-' + index
        const mermaidDefinition = mermaidThemeConfig + mermaidSrc.textContent
        mermaid.mermaidAPI.render(mermaidID, mermaidDefinition, (svgCode) => {
          mermaidSrc.insertAdjacentHTML('afterend', svgCode)
        })
      })
    }

    const loadMermaid = () => {
      window.loadMermaid ? runMermaid() : getScript('https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js').then(runMermaid)
    }

    window.pjax ? loadMermaid() : document.addEventListener('DOMContentLoaded', loadMermaid)
  }
})()</script><script>function loadValine () {
  function initValine () {
    const valine = new Valine(Object.assign({
      el: '#vcomment',
      appId: '',
      appKey: '',
      avatar: 'monsterid',
      serverURLs: '',
      emojiMaps: "",
      path: window.location.pathname,
      visitor: false
    }, null))
  }

  if (typeof Valine === 'function') initValine() 
  else getScript('https://cdn.jsdelivr.net/npm/valine/dist/Valine.min.js').then(initValine)
}

if ('Valine' === 'Valine' || !true) {
  if (true) btf.loadComment(document.getElementById('vcomment'),loadValine)
  else setTimeout(loadValine, 0)
} else {
  function loadOtherComment () {
    loadValine()
  }
}</script></div><div class="aplayer no-destroy" data-id="7625372994" data-server="netease" data-type="playlist" data-fixed="true" data-autoplay="true"> </div> <script defer src="https://npm.elemecdn.com/jquery@latest/dist/jquery.min.js"></script> <script src="/swiper/swiper.min.js"></script> <script src="/swiper/swiperindex.js"></script> <script src="//cdn.bootcss.com/pace/1.0.2/pace.min.js"></script> <script src="/js/title.js"></script> <script defer data-pjax src="/js/cat.js"></script> <script defer data-pjax src="/js/rightMenu.js"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = false;
POWERMODE.mobile = false;
document.body.addEventListener('input', POWERMODE);
</script><script id="click-heart" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/click-heart.min.js" async="async" mobile="false"></script><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/metingjs/dist/Meting.min.js"></script><script src="https://cdn.jsdelivr.net/npm/pjax/pjax.min.js"></script><script>let pjaxSelectors = ["head > title","#config-diff","#body-wrap","#rightside-config-hide","#rightside-config-show","#web_bg",".js-pjax"]

var pjax = new Pjax({
  elements: 'a:not([target="_blank"])',
  selectors: pjaxSelectors,
  cacheBust: false,
  analytics: false,
  scrollRestoration: false
})

document.addEventListener('pjax:send', function () {

  // removeEventListener scroll 
  window.tocScrollFn && window.removeEventListener('scroll', window.tocScrollFn)
  window.scrollCollect && window.removeEventListener('scroll', scrollCollect)

  typeof preloader === 'object' && preloader.initLoading()
  document.getElementById('rightside').style.cssText = "opacity: ''; transform: ''"
  
  if (window.aplayers) {
    for (let i = 0; i < window.aplayers.length; i++) {
      if (!window.aplayers[i].options.fixed) {
        window.aplayers[i].destroy()
      }
    }
  }

  typeof typed === 'object' && typed.destroy()

  //reset readmode
  const $bodyClassList = document.body.classList
  $bodyClassList.contains('read-mode') && $bodyClassList.remove('read-mode')

  typeof disqusjs === 'object' && disqusjs.destroy()
})

document.addEventListener('pjax:complete', function () {
  window.refreshFn()

  document.querySelectorAll('script[data-pjax]').forEach(item => {
    const newScript = document.createElement('script')
    const content = item.text || item.textContent || item.innerHTML || ""
    Array.from(item.attributes).forEach(attr => newScript.setAttribute(attr.name, attr.value))
    newScript.appendChild(document.createTextNode(content))
    item.parentNode.replaceChild(newScript, item)
  })

  GLOBAL_CONFIG.islazyload && window.lazyLoadInstance.update()

  typeof chatBtnFn === 'function' && chatBtnFn()
  typeof panguInit === 'function' && panguInit()

  // google analytics
  typeof gtag === 'function' && gtag('config', '', {'page_path': window.location.pathname});

  // baidu analytics
  typeof _hmt === 'object' && _hmt.push(['_trackPageview',window.location.pathname]);

  typeof loadMeting === 'function' && document.getElementsByClassName('aplayer').length && loadMeting()

  // prismjs
  typeof Prism === 'object' && Prism.highlightAll()

  typeof preloader === 'object' && preloader.endLoading()
})

document.addEventListener('pjax:error', (e) => {
  if (e.request.status === 404) {
    pjax.loadUrl('/404.html')
  }
})</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div><!-- hexo injector body_end start --><script data-pjax>function history_calendar_injector_config(){
                var parent_div_git = document.getElementsByClassName('sticky_layout')[0];
                var item_html = '<div class="card-widget card-history"><div class="card-content"><div class="item-headline"><i class="fas fa-clock fa-spin"></i><span>那年今日</span></div><div id="history-baidu" style="height: 100px;overflow: hidden"><div class="history_swiper-container" id="history-container" style="width: 100%;height: 100%"><div class="swiper-wrapper" id="history_container_wrapper" style="height:20px"></div></div></div></div>';
                console.log('已挂载history_calendar')
                // parent_div_git.innerHTML=item_html+parent_div_git.innerHTML // 无报错，但不影响使用(支持pjax跳转)
                parent_div_git.insertAdjacentHTML("afterbegin",item_html) // 有报错，但不影响使用(支持pjax跳转)
            }if( document.getElementsByClassName('sticky_layout')[0] && (location.pathname ==='/'|| '/' ==='all')){

            history_calendar_injector_config()
        } </script><script data-pjax  src="https://cdn.jsdelivr.net/npm/swiper/swiper-bundle.min.js"></script><script data-pjax src="https://cdn.jsdelivr.net/gh/Zfour/Butterfly-card-history/baiduhistory/js/main.js"></script><script data-pjax>
    function butterfly_categories_card_injector_config(){
      var parent_div_git = document.getElementById('recent-posts');
      var item_html = '<style>li.categoryBar-list-item{width:24%;}.categoryBar-list{max-height: 190px;overflow:auto;}.categoryBar-list::-webkit-scrollbar{width:0!important}@media screen and (max-width: 650px){.categoryBar-list{max-height: 160px;}}</style><div class="recent-post-item" style="height:auto;width:100%;padding:0px;"><div id="categoryBar"><ul class="categoryBar-list"><li class="categoryBar-list-item" style="background:url(https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpicnew6.photophoto.cn%2F20120106%2Fhaimianbaobaotupian-10036689_1.jpg&amp;refer=http%3A%2F%2Fpicnew6.photophoto.cn&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=auto?sec=1665648815&amp;t=a3deb15ddd7a38597964c3a05e519bd7);"> <a class="categoryBar-list-link" onclick="pjax.loadUrl(&quot;categories/Asp-Net/&quot;);" href="javascript:void(0);">Asp.Net</a><span class="categoryBar-list-count">1</span><span class="categoryBar-list-descr"></span></li><li class="categoryBar-list-item" style="background:url(https://npm.elemecdn.com/anzhiyu-blog@1.1.6/img/post/common/site-backgound.jpg);"> <a class="categoryBar-list-link" onclick="pjax.loadUrl(&quot;categories/C-系列/&quot;);" href="javascript:void(0);">C#系列</a><span class="categoryBar-list-count">8</span><span class="categoryBar-list-descr"></span></li><li class="categoryBar-list-item" style="background:url(https://gimg2.baidu.com/image_search/src=http%3A%2F%2Finews.gtimg.com%2Fnewsapp_bt%2F0%2F13012860773%2F1000.jpg&amp;refer=http%3A%2F%2Finews.gtimg.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=auto?sec=1665648865&amp;t=1d2f13b52a7e279e8801545f59eda4e7);"> <a class="categoryBar-list-link" onclick="pjax.loadUrl(&quot;categories/Hexo重装记录/&quot;);" href="javascript:void(0);">Hexo重装记录</a><span class="categoryBar-list-count">2</span><span class="categoryBar-list-descr"></span></li><li class="categoryBar-list-item" style="background:url(https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fblog%2F202011%2F07%2F20201107183300_ac0c5.thumb.1000_0.jpeg&amp;refer=http%3A%2F%2Fc-ssl.duitang.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=auto?sec=1665648887&amp;t=3d32c6b12a4cf12e5cec3585b79c1fc3);"> <a class="categoryBar-list-link" onclick="pjax.loadUrl(&quot;categories/EF/&quot;);" href="javascript:void(0);">EF</a><span class="categoryBar-list-count">1</span><span class="categoryBar-list-descr"></span></li><li class="categoryBar-list-item" style="background:url(https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fup.enterdesk.com%2Fedpic%2F25%2Feb%2F1f%2F25eb1fd40b5a740c2b79e33f700806e5.jpg&amp;refer=http%3A%2F%2Fup.enterdesk.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=auto?sec=1665648908&amp;t=6425ee3bd166b0f5c5ffa6fb18b6937b);"> <a class="categoryBar-list-link" onclick="pjax.loadUrl(&quot;categories/LOL/&quot;);" href="javascript:void(0);">LOL</a><span class="categoryBar-list-count">1</span><span class="categoryBar-list-descr"></span></li><li class="categoryBar-list-item" style="background:url(https://gimg2.baidu.com/image_search/src=http%3A%2F%2Flmg.jj20.com%2Fup%2Fallimg%2Ftx26%2F36080017392073.jpg&amp;refer=http%3A%2F%2Flmg.jj20.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=auto?sec=1665650136&amp;t=5cc414d0ee58c9e285218d92f6a95513);"> <a class="categoryBar-list-link" onclick="pjax.loadUrl(&quot;categories/idea/&quot;);" href="javascript:void(0);">idea</a><span class="categoryBar-list-count">1</span><span class="categoryBar-list-descr"></span></li><li class="categoryBar-list-item" style="background:url(https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fn.sinaimg.cn%2Fsinacn10%2F320%2Fw700h420%2F20180907%2F5116-hitesuz6599636.jpg&amp;refer=http%3A%2F%2Fn.sinaimg.cn&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=auto?sec=1665650004&amp;t=6a304aa9cc7435ec1d148b8f99092bc0);"> <a class="categoryBar-list-link" onclick="pjax.loadUrl(&quot;categories/世界/&quot;);" href="javascript:void(0);">世界</a><span class="categoryBar-list-count">1</span><span class="categoryBar-list-descr"></span></li><li class="categoryBar-list-item" style="background:url(https://s1.ax1x.com/2022/11/15/zAxCi6.jpg);"> <a class="categoryBar-list-link" onclick="pjax.loadUrl(&quot;categories/世界见闻录/&quot;);" href="javascript:void(0);">世界见闻录</a><span class="categoryBar-list-count">8</span><span class="categoryBar-list-descr"></span></li><li class="categoryBar-list-item" style="background:url(https://s1.ax1x.com/2022/11/15/zAxFzD.jpg);"> <a class="categoryBar-list-link" onclick="pjax.loadUrl(&quot;categories/前端体系/&quot;);" href="javascript:void(0);">前端体系</a><span class="categoryBar-list-count">19</span><span class="categoryBar-list-descr"></span></li><li class="categoryBar-list-item" style="background:url(https://s1.ax1x.com/2022/11/15/zAxnot.jpg);"> <a class="categoryBar-list-link" onclick="pjax.loadUrl(&quot;categories/副业/&quot;);" href="javascript:void(0);">副业</a><span class="categoryBar-list-count">1</span><span class="categoryBar-list-descr"></span></li><li class="categoryBar-list-item" style="background:url(https://s1.ax1x.com/2022/11/15/zAxMJf.jpg);"> <a class="categoryBar-list-link" onclick="pjax.loadUrl(&quot;categories/文案/&quot;);" href="javascript:void(0);">文案</a><span class="categoryBar-list-count">6</span><span class="categoryBar-list-descr"></span></li><li class="categoryBar-list-item" style="background:url(https://s1.ax1x.com/2022/11/15/zAxQW8.jpg);"> <a class="categoryBar-list-link" onclick="pjax.loadUrl(&quot;categories/办公日常/&quot;);" href="javascript:void(0);">办公日常</a><span class="categoryBar-list-count">2</span><span class="categoryBar-list-descr"></span></li><li class="categoryBar-list-item" style="background:url(https://s1.ax1x.com/2022/11/15/zAx3Qg.jpg);"> <a class="categoryBar-list-link" onclick="pjax.loadUrl(&quot;categories/朝花夕拾/&quot;);" href="javascript:void(0);">朝花夕拾</a><span class="categoryBar-list-count">12</span><span class="categoryBar-list-descr"></span></li><li class="categoryBar-list-item" style="background:url(https://s1.ax1x.com/2022/11/15/zAxYes.jpg);"> <a class="categoryBar-list-link" onclick="pjax.loadUrl(&quot;categories/前端/&quot;);" href="javascript:void(0);">前端</a><span class="categoryBar-list-count">20</span><span class="categoryBar-list-descr"></span></li><li class="categoryBar-list-item" style="background:url(undefined);"> <a class="categoryBar-list-link" onclick="pjax.loadUrl(&quot;categories/杂七杂八/&quot;);" href="javascript:void(0);">杂七杂八</a><span class="categoryBar-list-count">7</span><span class="categoryBar-list-descr"></span></li><li class="categoryBar-list-item" style="background:url(undefined);"> <a class="categoryBar-list-link" onclick="pjax.loadUrl(&quot;categories/简书/&quot;);" href="javascript:void(0);">简书</a><span class="categoryBar-list-count">5</span><span class="categoryBar-list-descr"></span></li><li class="categoryBar-list-item" style="background:url(undefined);"> <a class="categoryBar-list-link" onclick="pjax.loadUrl(&quot;categories/游戏/&quot;);" href="javascript:void(0);">游戏</a><span class="categoryBar-list-count">1</span><span class="categoryBar-list-descr"></span></li></ul></div></div>';
      console.log('已挂载butterfly_categories_card')
      parent_div_git.insertAdjacentHTML("afterbegin",item_html)
      }
    if( document.getElementById('recent-posts') && (location.pathname ==='/'|| '/' ==='all')){
    butterfly_categories_card_injector_config()
    }
  </script><script data-pjax>
  function butterfly_clock_anzhiyu_injector_config(){
    var parent_div_git = document.getElementsByClassName('sticky_layout')[0];
    var item_html = '<div class="card-widget card-clock"><div class="card-glass"><div class="card-background"><div class="card-content"><div id="hexo_electric_clock"><img class="entered loading" id="card-clock-loading" src= "" data-lazy-src="https://cdn.cbd.int/hexo-butterfly-clock-anzhiyu/lib/loading.gif" style="height: 120px; width: 100%;" data-ll-status="loading"/></div></div></div></div></div>';
    console.log('已挂载butterfly_clock_anzhiyu')
    parent_div_git.insertAdjacentHTML("afterbegin",item_html)
    }
  var elist = 'null'.split(',');
  var cpage = location.pathname;
  var epage = '/';
  var qweather_key = '41ea442da35546559913a6a5d54163b2';
  var gaud_map_key = '6b62fbebf584b9a22a85bfccbf90335e';
  var baidu_ak_key = 'undefined';
  var flag = 0;
  var clock_rectangle = '114.35,34.79';
  var clock_default_rectangle_enable = 'true';

  for (var i=0;i<elist.length;i++){
    if (cpage.includes(elist[i])){
      flag++;
    }
  }

  if ((epage ==='all')&&(flag == 0)){
    butterfly_clock_anzhiyu_injector_config();
  }
  else if (epage === cpage){
    butterfly_clock_anzhiyu_injector_config();
  }
  </script><script src="https://widget.qweather.net/simple/static/js/he-simple-common.js?v=2.0"></script><script data-pjax src="https://cdn.cbd.int/hexo-butterfly-clock-anzhiyu/lib/clock.min.js"></script><script data-pjax>
  function butterfly_footer_beautify_injector_config(){
    var parent_div_git = document.getElementById('footer-wrap');
    var item_html = '<div id="workboard"></div><p id="ghbdages"><a class="github-badge" target="_blank" href="https://hexo.io/" style="margin-inline:5px" data-title="博客框架为Hexo_v5.4.0" title=""><img src= "" data-lazy-src="https://img.shields.io/badge/Frame-Hexo-blue?style=flat&amp;logo=hexo" alt=""/></a><a class="github-badge" target="_blank" href="https://butterfly.js.org/" style="margin-inline:5px" data-title="主题版本Butterfly_v4.2.2" title=""><img src= "" data-lazy-src="https://img.shields.io/badge/Theme-Butterfly-6513df?style=flat&amp;logo=bitdefender" alt=""/></a><a class="github-badge" target="_blank" href="https://www.jsdelivr.com/" style="margin-inline:5px" data-title="本站使用JsDelivr为静态资源提供CDN加速" title=""><img src= "" data-lazy-src="https://img.shields.io/badge/CDN-jsDelivr-orange?style=flat&amp;logo=jsDelivr" alt=""/></a><a class="github-badge" target="_blank" href="http://creativecommons.org/licenses/by-nc-sa/4.0/" style="margin-inline:5px" data-title="本站采用知识共享署名-非商业性使用-相同方式共享4.0国际许可协议进行许可" title=""><img src= "" data-lazy-src="https://img.shields.io/badge/Copyright-BY--NC--SA%204.0-d42328?style=flat&amp;logo=Claris" alt=""/></a></p>';
    console.log('已挂载butterfly_footer_beautify')
    parent_div_git.insertAdjacentHTML("beforeend",item_html)
    }
  var elist = 'null'.split(',');
  var cpage = location.pathname;
  var epage = 'all';
  var flag = 0;

  for (var i=0;i<elist.length;i++){
    if (cpage.includes(elist[i])){
      flag++;
    }
  }

  if ((epage ==='all')&&(flag == 0)){
    butterfly_footer_beautify_injector_config();
  }
  else if (epage === cpage){
    butterfly_footer_beautify_injector_config();
  }
  </script><script async src="/js/runtime/runtime.min.js"></script><script data-pjax>
  function butterfly_swiper_injector_config(){
    var parent_div_git = document.getElementById('recent-posts');
    var item_html = '<div class="recent-post-item swiper_container_card" style="height: auto;width: 100%"><div id="random"><div id="random-banner"><canvas id="peoplecanvas"></canvas></div><a id="random-hover" style="width:100%;height:auto;" href="javascript:toRandomPost()" rel="external nofollow noreferrer" one-link-mark="yes"><i class="fa fa-paper-plane" style="margin-left:10px"></i><div style="margin-left:10px">随便逛逛<i class="fa-solid fa-arrow-right" style="margin-left:10px"></i></div></a></div><div class="blog-slider swiper-container-fade swiper-container-horizontal" id="swiper_container"><div class="blog-slider__wrp swiper-wrapper" style="transition-duration: 0ms;"><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" onclick="pjax.loadUrl(&quot;posts/67fcd28d.html&quot;);" href="javascript:void(0);" alt=""><img width="48" height="48" src= "" data-lazy-src="https://img2.baidu.com/it/u=4087346614,241521689&amp;fm=253&amp;fmt=auto&amp;app=138&amp;f=JPEG?w=500&amp;h=333" alt="" onerror="this.src=https://cdn.cbd.int/akilar-candyassets/image/loading.gif; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2022-09-19</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;posts/67fcd28d.html&quot;);" href="javascript:void(0);" alt="">学生人到职业人_心态篇</a><div class="blog-slider__text">再怎么看我也不知道怎么描述它的啦！</div><a class="blog-slider__button" onclick="pjax.loadUrl(&quot;posts/67fcd28d.html&quot;);" href="javascript:void(0);" alt="">详情       </a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" onclick="pjax.loadUrl(&quot;posts/8a73f76c.html&quot;);" href="javascript:void(0);" alt=""><img width="48" height="48" src= "" data-lazy-src="https://s1.ax1x.com/2022/11/04/xLiBTA.jpg" alt="" onerror="this.src=https://cdn.cbd.int/akilar-candyassets/image/loading.gif; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2022-11-04</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;posts/8a73f76c.html&quot;);" href="javascript:void(0);" alt="">生活の奇思妙想☞2022</a><div class="blog-slider__text">再怎么看我也不知道怎么描述它的啦！</div><a class="blog-slider__button" onclick="pjax.loadUrl(&quot;posts/8a73f76c.html&quot;);" href="javascript:void(0);" alt="">详情       </a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" onclick="pjax.loadUrl(&quot;posts/14e5dae6.html&quot;);" href="javascript:void(0);" alt=""><img width="48" height="48" src= "" data-lazy-src="https://s1.ax1x.com/2022/10/21/xcAQDH.jpg" alt="" onerror="this.src=https://cdn.cbd.int/akilar-candyassets/image/loading.gif; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2022-11-12</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;posts/14e5dae6.html&quot;);" href="javascript:void(0);" alt="">少年自负凌云笔</a><div class="blog-slider__text">再怎么看我也不知道怎么描述它的啦！</div><a class="blog-slider__button" onclick="pjax.loadUrl(&quot;posts/14e5dae6.html&quot;);" href="javascript:void(0);" alt="">详情       </a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" onclick="pjax.loadUrl(&quot;posts/9b7092b7.html&quot;);" href="javascript:void(0);" alt=""><img width="48" height="48" src= "" data-lazy-src="https://s1.ax1x.com/2022/10/11/xNJbF0.jpg" alt="" onerror="this.src=https://cdn.cbd.int/akilar-candyassets/image/loading.gif; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2022-09-13</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;posts/9b7092b7.html&quot;);" href="javascript:void(0);" alt="">租房有感</a><div class="blog-slider__text">再怎么看我也不知道怎么描述它的啦！</div><a class="blog-slider__button" onclick="pjax.loadUrl(&quot;posts/9b7092b7.html&quot;);" href="javascript:void(0);" alt="">详情       </a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" onclick="pjax.loadUrl(&quot;posts/94bbc7d.html&quot;);" href="javascript:void(0);" alt=""><img width="48" height="48" src= "" data-lazy-src="https://s1.ax1x.com/2022/10/11/xNJLWT.jpg" alt="" onerror="this.src=https://cdn.cbd.int/akilar-candyassets/image/loading.gif; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2022-09-25</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;posts/94bbc7d.html&quot;);" href="javascript:void(0);" alt="">谷歌收藏</a><div class="blog-slider__text">再怎么看我也不知道怎么描述它的啦！</div><a class="blog-slider__button" onclick="pjax.loadUrl(&quot;posts/94bbc7d.html&quot;);" href="javascript:void(0);" alt="">详情       </a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" onclick="pjax.loadUrl(&quot;posts/3b350f14.html&quot;);" href="javascript:void(0);" alt=""><img width="48" height="48" src= "" data-lazy-src="https://s1.ax1x.com/2022/10/11/xNJJd1.jpg" alt="" onerror="this.src=https://cdn.cbd.int/akilar-candyassets/image/loading.gif; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2022-09-13</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;posts/3b350f14.html&quot;);" href="javascript:void(0);" alt="">阳光不燥、微风正好</a><div class="blog-slider__text">再怎么看我也不知道怎么描述它的啦！</div><a class="blog-slider__button" onclick="pjax.loadUrl(&quot;posts/3b350f14.html&quot;);" href="javascript:void(0);" alt="">详情       </a></div></div></div><div class="blog-slider__pagination swiper-pagination-clickable swiper-pagination-bullets"></div></div></div>';
    console.log('已挂载butterfly_swiper')
    parent_div_git.insertAdjacentHTML("afterbegin",item_html)
    }
  var elist = 'undefined'.split(',');
  var cpage = location.pathname;
  var epage = '/';
  var flag = 0;

  for (var i=0;i<elist.length;i++){
    if (cpage.includes(elist[i])){
      flag++;
    }
  }

  if ((epage ==='all')&&(flag == 0)){
    butterfly_swiper_injector_config();
  }
  else if (epage === cpage){
    butterfly_swiper_injector_config();
  }
  </script><script defer src="https://npm.elemecdn.com/anzhiyu-blog@1.1.6/js/swiper.min.js"></script><script defer data-pjax src="https://cdn.cbd.int/hexo-butterfly-swiper-anzhiyu@1.0.4/lib/swiper_init.js"></script><script data-pjax src="https://lf26-cdn-tos.bytecdntp.com/cdn/expire-1-M/gsap/3.9.1/gsap.min.js"></script><script defer src="https://npm.elemecdn.com/hexo-butterfly-swiper-anzhiyu@1.0.4/lib/people.min.js"></script><script async src="/anzhiyu/random.js"></script><div class="js-pjax"><script async="async">var arr = document.getElementsByClassName('recent-post-item');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__zoomIn');
    arr[i].setAttribute('data-wow-duration', '1.5s');
    arr[i].setAttribute('data-wow-delay', '200ms');
    arr[i].setAttribute('data-wow-offset', '30');
    arr[i].setAttribute('data-wow-iteration', '1');
  }</script><script async="async">var arr = document.getElementsByClassName('card-widget');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__zoomIn');
    arr[i].setAttribute('data-wow-duration', '');
    arr[i].setAttribute('data-wow-delay', '200ms');
    arr[i].setAttribute('data-wow-offset', '');
    arr[i].setAttribute('data-wow-iteration', '');
  }</script><script async="async">var arr = document.getElementsByClassName('flink-list-card');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__flipInY');
    arr[i].setAttribute('data-wow-duration', '3s');
    arr[i].setAttribute('data-wow-delay', '');
    arr[i].setAttribute('data-wow-offset', '');
    arr[i].setAttribute('data-wow-iteration', '');
  }</script><script async="async">var arr = document.getElementsByClassName('flink-list-card');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__animated');
    arr[i].setAttribute('data-wow-duration', '3s');
    arr[i].setAttribute('data-wow-delay', '');
    arr[i].setAttribute('data-wow-offset', '');
    arr[i].setAttribute('data-wow-iteration', '');
  }</script><script async="async">var arr = document.getElementsByClassName('article-sort-item');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__slideInRight');
    arr[i].setAttribute('data-wow-duration', '1.5s');
    arr[i].setAttribute('data-wow-delay', '');
    arr[i].setAttribute('data-wow-offset', '');
    arr[i].setAttribute('data-wow-iteration', '');
  }</script><script async="async">var arr = document.getElementsByClassName('site-card');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__flipInY');
    arr[i].setAttribute('data-wow-duration', '3s');
    arr[i].setAttribute('data-wow-delay', '');
    arr[i].setAttribute('data-wow-offset', '');
    arr[i].setAttribute('data-wow-iteration', '');
  }</script><script async="async">var arr = document.getElementsByClassName('site-card');
for(var i = 0;i<arr.length;i++){
    arr[i].classList.add('wow');
    arr[i].classList.add('animate__animated');
    arr[i].setAttribute('data-wow-duration', '3s');
    arr[i].setAttribute('data-wow-delay', '');
    arr[i].setAttribute('data-wow-offset', '');
    arr[i].setAttribute('data-wow-iteration', '');
  }</script></div><script defer src="https://cdn.cbd.int/hexo-butterfly-wowjs/lib/wow.min.js"></script><script defer src="https://cdn.cbd.int/hexo-butterfly-wowjs/lib/wow_init.js"></script><script async src="/js/ali_font.js"></script><!-- hexo injector body_end end --><script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"tagMode":false,"debug":false,"model":{"jsonPath":"/live2dw/assets/koharu.model.json"},"display":{"position":"left","width":150,"height":300},"mobile":{"show":false},"log":false,"pluginJsPath":"lib/","pluginModelPath":"assets/","pluginRootPath":"live2dw/"});</script></body></html>